1+ name : Release to production
2+ on :
3+ release :
4+ types : [published]
5+ jobs :
6+ build :
7+ runs-on : ubuntu-latest
8+ steps :
9+ - name : Checkout
10+ uses : actions/checkout@v2
11+ - name : Set up Docker Buildx
12+ uses : docker/setup-buildx-action@v1
13+ - name : Cache Docker layers
14+ uses : actions/cache@v2
15+ with :
16+ path : /tmp/.buildx-cache
17+ key : ${{ runner.os }}-buildx-${{ github.sha }}
18+ restore-keys : |
19+ ${{ runner.os }}-buildx-
20+ - name : Login to GitHub Container Registry
21+ uses : docker/login-action@v1
22+ with :
23+ registry : ghcr.io
24+ username : ${{ github.repository_owner }}
25+ password : ${{ secrets.GITHUB_TOKEN }}
26+ - name : Get git tag
27+ run : |
28+ echo "::set-output name=GIT_TAG::$(git tag --points-at HEAD)"
29+ id : set_git_vars
30+ - name : Push to GitHub Packages
31+ uses : docker/build-push-action@v2
32+ with :
33+ context : .
34+ file : ./Dockerfile
35+ push : true
36+ tags : ghcr.io/${{ github.repository }}:${{ steps.set_git_vars.outputs.GIT_TAG }}
37+ cache-from : type=local,src=/tmp/.buildx-cache
38+ cache-to : type=local,dest=/tmp/.buildx-cache
39+
40+ deploy :
41+ needs : [build]
42+ runs-on : ubuntu-latest
43+ env :
44+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
45+ steps :
46+ - name : Checkout
47+ uses : actions/checkout@v2
48+
49+ - name : Extract variables
50+ shell : bash
51+ run : |
52+ echo "::set-output name=BRANCH::$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')"
53+ echo "::set-output name=TAG::$(git tag --points-at HEAD)"
54+ echo "::set-output name=GIT_SHA::$(git rev-parse HEAD)"
55+ echo "::set-output name=GIT_SHA_SHORT::$(git rev-parse --short HEAD)"
56+ id : extract_variables
57+
58+ - name : Checkout terraform config repo
59+ uses : actions/checkout@v2
60+ with :
61+ # public repo with terraform configuration
62+ repository : ' datacite/mastino'
63+ persist-credentials : false
64+ - name : Commit changes to terraform config repository
65+ # use go template in terraform config repository to update git sha and tag
66+ # commit and push changes to trigger terraform workflow
67+ run : |
68+ export GIT_SHA=${{ steps.extract_variables.outputs.GIT_SHA_SHORT }}
69+ export GIT_TAG=${{ steps.extract_variables.outputs.TAG }}
70+ wget https://github.com/jwilder/dockerize/releases/download/v0.6.0/dockerize-linux-amd64-v0.6.0.tar.gz
71+ tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz
72+ rm dockerize-linux-amd64-v0.6.0.tar.gz
73+ ./dockerize -template prod-eu-west/services/oai/_viringo.auto.tfvars.tmpl:prod-eu-west/services/oai/_viringo.auto.tfvars
74+
75+ git config --local user.email "action@github.com"
76+ git config --local user.name "GitHub Action"
77+ git add prod-eu-west/services/oai/_viringo.auto.tfvars
78+ git commit -m "Adding viringo (oai) git variables for tag ${{ steps.extract_variables.outputs.GIT_TAG }}"
79+ - name : Push changes
80+ uses : ad-m/github-push-action@v0.6.0
81+ with :
82+ github_token : ${{ secrets.PERSONAL_ACCESS_TOKEN }}
83+ repository : ' datacite/mastino'
84+ branch : ' refs/heads/master'
85+ tags : false
0 commit comments