-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (53 loc) · 2.56 KB
/
deploy_app.yml
File metadata and controls
54 lines (53 loc) · 2.56 KB
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
54
name: deploy_app
on:
push:
branches:
- dev
jobs:
Build-safety-data-client:
if: github.repository == "${{ github.repository_owner }}/safety-data-client"
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Short SHA
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Build and push safety-data-client Docker image
uses: docker/build-push-action@v6
with:
file: Dockerfile.prod
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/safety-data-client:latest
ghcr.io/${{ github.repository_owner }}/safety-data-client:sha-${{ env.SHORT_SHA }}
build-args: |
REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}
VITE_API_URL=${{ secrets.VITE_API_URL }}
VITE_API_ANYWAY_URL=${{ secrets.VITE_API_ANYWAY_URL }}
deploy:
needs: Build-safety-data-client
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- env:
SAFETY_DATA_CLIENT_IMAGE_NAME: ghcr.io/data-for-change/safety-data-client
DFC_IAC_DEPLOY_KEY: ${{ secrets.DFC_IAC_DEPLOY_KEY }}
run: |
SHA_TAG=sha-`git rev-parse --short $GITHUB_SHA` &&\
echo SHA_TAG=$SHA_TAG &&\
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 git@github.com:data-for-change/dfc-iac.git &&\
cd dfc-iac &&\
SAFETY_DATA_CLIENT_IMAGE="${SAFETY_DATA_CLIENT_IMAGE_NAME}:${SHA_TAG}" &&\
bin/update_anyway_env.py '{"safetyDataClientImage":"'${SAFETY_DATA_CLIENT_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 (safety data)" &&\
git push origin main