A flexible GitHub Action for building and deploying applications using Skaffold.
default-repo
: Container registry URL (e.g., 'gcr.io/my-project')
skaffold-version
: Skaffold version (default: 'latest')command
: Skaffold command to run (default: 'run')profile
: Skaffold profile namefilename
: Path to skaffold.yaml (default: 'skaffold.yaml')namespace
: Kubernetes namespacetag
: Custom tag for imagesshort-hash
: Include git short hash in tag (default: 'false')cache-file
: Path to cache filebuild-artifacts
: Path to build artifacts filecollect-metrics
: Enable/disable Skaffold metrics collection (default: 'false')
- uses: your-org/skaffold-github-action@main
with:
command: 'build'
default-repo: 'gcr.io/my-project'
- uses: your-org/skaffold-github-action@main
with:
command: 'build'
profile: 'prod'
tag: 'release-1.0'
short-hash: 'true'
default-repo: 'gcr.io/my-project'
- uses: your-org/skaffold-github-action@main
with:
command: 'deploy'
profile: 'prod'
namespace: 'production'
default-repo: 'gcr.io/my-project'
- uses: your-org/skaffold-github-action@main
with:
command: 'diagnose'
filename: './path/to/skaffold.yaml'
name: Build and Deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Important for git operations
# Optional: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login to Container Registry
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.CONTAINER_REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# Build Phase
- uses: your-org/skaffold-github-action@main
with:
command: 'build'
profile: 'prod'
tag: 'release'
short-hash: 'true'
filename: './infrastructure/stage/skaffold.yaml'
default-repo: ${{ vars.CONTAINER_REGISTRY }}
collect-metrics: 'false'
# Deploy Phase
- uses: your-org/skaffold-github-action@main
with:
command: 'deploy'
profile: 'prod'
namespace: 'production'
default-repo: ${{ vars.CONTAINER_REGISTRY }}
The action supports these Skaffold command flags:
filename/-f
: Set skaffold.yaml locationprofile/-p
: Use specific profilenamespace/-n
: Deploy to specific namespacetag
: Set custom tagdefault-repo
: Override default repositorycache-file
: Specify cache file locationbuild-artifacts
: Specify build artifacts file
your-project/
├── apps/
├── infrastructure/
│ ├── environments/
│ ├── k8s-scripts/
│ ├── manifests/
│ ├── stage/
│ │ └── skaffold.yaml
│ └── scripts/
├── [...]
└── README.md
The action supports all standard Skaffold environment variables:
SKAFFOLD_DEFAULT_REPO
SKAFFOLD_CACHE_FILE
SKAFFOLD_NAMESPACE
SKAFFOLD_PROFILE
Use GitHub's cache action to speed up builds:
- uses: actions/cache@v3
with:
path: ~/.skaffold/
key: ${{ runner.os }}-skaffold-${{ hashFiles('**/skaffold.yaml') }}
- uses: your-org/skaffold-github-action@main
with:
command: 'run'
profile: 'prod,monitoring'
- uses: your-org/skaffold-github-action@main
with:
command: 'debug'
profile: 'dev'
- uses: your-org/skaffold-github-action@main
with:
command: 'build'
filename: './services/myapp/skaffold.yaml'
- The action automatically handles Skaffold installation
- Git short hash in tags is optional and controlled by the
short-hash
input - Metrics collection is disabled by default
- The action supports all major Skaffold commands and configurations
- Registry URLs should be stored as GitHub Variables, not Secrets