-
Notifications
You must be signed in to change notification settings - Fork 17
49 lines (45 loc) · 1.52 KB
/
build-container-images.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
name: Build indicator container images and upload to registry
on:
push:
branches: [main, prod]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
packages: [backfill_corrections]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: cmu-delphi-deploy-machine
password: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }}
- name: Build, tag, and push image to Github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
baseRef="${GITHUB_REF#*/}"
baseRef="${baseRef#*/}"
case "${baseRef}" in
main)
imageTag="dev"
;;
prod)
imageTag="latest"
;;
*)
imageTag="${baseRef//\//_}" # replace `/` with `_` in branch name
;;
esac
if [ -z ${{ matrix.packages }} ]; then
echo "The matrix list is empty so we will not build any images."
else
cd ${{ github.workspace }}/${{ matrix.packages }}
echo "using tag: --${imageTag}--"
DOCKER_BUILDKIT=1 BUILDKIT_PROGRESS=plain docker build --secret id=GITHUB_TOKEN -t ghcr.io/${{ github.repository }}-${{ matrix.packages }}:$imageTag --file Dockerfile .
docker push ghcr.io/${{ github.repository }}-${{ matrix.packages }}:$imageTag
fi