-
Notifications
You must be signed in to change notification settings - Fork 5
53 lines (50 loc) · 2.07 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Build Docker
on:
push:
branches: [ master ]
env:
DOCKER_REPOSITORY_ANYWAY_REPORTS: "${{ github.repository }}/anyway-reports"
REGISTRY_URL: "docker.pkg.github.com"
jobs:
Build-anyway-reports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and push anyway Docker image
uses: docker/[email protected]
with:
name: ${{ env.DOCKER_REPOSITORY_ANYWAY_REPORTS }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.REGISTRY_URL }}
repository: ${{ env.DOCKER_REPOSITORY_ANYWAY_REPORTS }}
tag_with_ref: true
tag_with_sha: true
cache_from: ${{ env.DOCKER_REPOSITORY_ANYWAY_REPORTS }}:master
deploy:
needs:
- Build-anyway-reports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- env:
DOCKER_REPOSITORY_ANYWAY_REPORTS: ${{ env.REGISTRY_URL }}/${{ env.DOCKER_REPOSITORY_ANYWAY_REPORTS }}
DFC_IAC_DEPLOY_KEY: ${{ secrets.DFC_IAC_DEPLOY_KEY }}
run: |
SHA_TAG=sha-`git rev-parse --short $GITHUB_SHA` &&\
echo SHA_TAG=$SHA_TAG &&\
ANYWAY_REPORTS_IMAGE="${DOCKER_REPOSITORY_ANYWAY_REPORTS}:${SHA_TAG}" &&\
echo ANYWAY_REPORTS_IMAGE=$ANYWAY_REPORTS_IMAGE &&\
if ! git log -1 --pretty=format:"%s" | grep -- --no-deploy; then
cd `mktemp -d` &&\
echo "${DFC_IAC_DEPLOY_KEY}" > dfc_iac_deploy_key &&\
chmod 400 dfc_iac_deploy_key &&\
export GIT_SSH_COMMAND="ssh -i `pwd`/dfc_iac_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" &&\
git clone [email protected]:data-for-change/dfc-iac.git &&\
cd dfc-iac &&\
bin/update_anyway_env.py '{"anywayReportsImage":"'${ANYWAY_REPORTS_IMAGE}'"}' &&\
git config --global user.name "Anyway CI" &&\
git config --global user.email "anyway-ci@localhost" &&\
git add apps/anyway/.env && git commit -m "automatic update of anyway-report docker image" &&\
git push origin main
fi