Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
morphy2k committed Mar 16, 2023
1 parent 9d31233 commit b0d450c
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions .github/workflows/build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -31,26 +31,37 @@ jobs:
name: Deploy
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
id-token: write
env:
NAMESPACE: production
DEPLOYMENT: tileserver
CONTAINER: tileserver
steps:

- name: Check out
uses: actions/checkout@v3

- name: Set up config
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
run: |
mkdir -p ${HOME}/.kube
export KUBECONFIG=${HOME}/.kube/config
echo $KUBE_CONFIG | base64 -d > $KUBECONFIG
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
workload_identity_provider: '${{ secrets.GC_WORKLOAD_IDENTITY_PROVIDER }}'
service_account: '${{ secrets.GC_SERVICE_ACCOUNT }}'

- name: Get GKE cluster credentials
uses: google-github-actions/get-gke-credentials@v1
with:
cluster_name: '${{ secrets.GC_GKE_CLUSTER_NAME }}'
location: '${{ secrets.GC_GKE_CLUSTER_LOCATION }}'

- name: Deploy image
run: kubectl set image deployment/${DEPLOYMENT} ${CONTAINER}=ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_REF#refs/tags/v}
run: kubectl -n ${NAMESPACE} set image deployment/${DEPLOYMENT} ${CONTAINER}=ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_REF#refs/tags/v}

- name: Check rollout
if: success()
run: kubectl rollout status deployment/${DEPLOYMENT} -w --timeout=5m
run: kubectl -n ${NAMESPACE} rollout status deployment/${DEPLOYMENT} -w --timeout=5m

- name: Roll back
if: failure()
run: kubectl rollout undo deployment/${DEPLOYMENT}
run: kubectl -n ${NAMESPACE} rollout undo deployment/${DEPLOYMENT}

0 comments on commit b0d450c

Please sign in to comment.