Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: main-worklfow
on:
workflow_dispatch:
push:
branches:
- master
- awesome-feature
pull_request:
branches:
- master
- awesome-feature
env:
IMAGE_REPOSITORY: ghcr.io/paez1999/foobar
jobs:
# Run all unit tests.
run-tests:
runs-on: ubuntu-latest
steps:
# Check out the pull request's source code.
- name: Check out source code
uses: actions/checkout@v3
# Install Go.
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "^1.14"
- name: Print Go version
run: go version
# Run unit tests.
- name: Run unit tests
run: go test -v ./...

# Build and release.
build-and-release:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Build and push container image
uses: docker/build-push-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ env.IMAGE_REPOSITORY }}
tag_with_ref: true
tag_with_sha: true

# Deploy to Kubernetes.
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs:
- run-tests
- build-and-release
steps:
- uses: actions/checkout@v3
- name: Configure kubectl
run: echo ${{ secrets.KUBECONFIG }} | base64 -d > kubeconfig.yml
- name: Kustomize image
working-directory: ./manifests
run: kustomize edit set image REPOSITORY:TAG=$IMAGE_REPOSITORY:sha-${GITHUB_SHA::7}
- name: Deploy to Kubernetes
run: kubectl --kubeconfig kubeconfig.yml apply --kustomize manifests/
- name: Validate deployment
run: kubectl --kubeconfig kubeconfig.yml rollout status --timeout 120s deployment/foobar