Skip to content

Commit

Permalink
moved auto deploy to the tag workflow; made deploy to prod manual only
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Jul 14, 2021
1 parent 4221f78 commit d88b33f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/deploy-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,19 @@ on:
tag:
description: Release
required: true
workflow_run:
workflows: [ 'Docker Tag Latest Release' ]
types: [ completed ]

env:
IMAGE_ID: ghcr.io/mlibrary/alma-webhook

jobs:
deploy:
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Clone latest repository
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check that the tag exists
if: ${{ github.event_name == 'workflow_dispatch' }}
id: tag_check
run: |
if git rev-parse 'refs/tags/${{ github.event.inputs.tag }}' &> /dev/null; then
Expand All @@ -45,9 +39,5 @@ jobs:
kubectl config set-credentials default --token=`echo ${{ secrets.HATCHER_PRODUCTION_TOKEN }} | base64 -d`
kubectl config set-context default --cluster=cluster --user=default --namespace=alma-webhook
kubectl config use-context default
- name: Automatic Deploy
if: ${{ github.event_name == 'workflow_run' }}
run: kubectl set image deployment web web=$IMAGE_ID:${{ github.ref }}
- name: Manual Deploy
if: ${{ github.event_name == 'workflow_dispatch' }}
run: kubectl set image deployment web web=$IMAGE_ID:${{ steps.tag_check.outputs.tag }}
13 changes: 12 additions & 1 deletion .github/workflows/tag-release.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Tag Latest Release
name: Docker Tag Latest Release and Deploy to Production

on:
release:
Expand All @@ -25,4 +25,15 @@ jobs:
docker tag $UNSTABLE_IMAGE_ID:${{ github.sha }} $PROD_IMAGE_ID:latest
docker push $PROD_IMAGE_ID:${{ github.event.release.tag_name }}
docker push $PROD_IMAGE_ID:latest
- uses: azure/setup-kubectl@v1
- name: Authenticate with kubernetes
run: |
mkdir -p ${HOME}/.kube/certs/cluster
echo ${{ secrets.HATCHER_CLUSTER_CA }} | base64 -d > ${HOME}/.kube/certs/cluster/k8s-ca.crt
kubectl config set-cluster cluster --certificate-authority=${HOME}/.kube/certs/cluster/k8s-ca.crt --server=https://hatcher.kubernetes.lib.umich.edu
kubectl config set-credentials default --token=`echo ${{ secrets.HATCHER_PRODUCTION_TOKEN }} | base64 -d`
kubectl config set-context default --cluster=cluster --user=default --namespace=alma-webhook
kubectl config use-context default
- name: Automatic Deploy to Production
run: kubectl set image deployment web web=$IMAGE_ID:${{ github.event.release.tag_name }}

0 comments on commit d88b33f

Please sign in to comment.