-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (48 loc) · 1.72 KB
/
containers.yaml
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
55
56
57
58
name: Create Docker Image
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
REGISTRY: cfaprdbatchcr.azurecr.io/
IMAGE_NAME: pyrenew-hew
jobs:
build-and-push-image:
runs-on: cfa-cdcgov
name: Build and push image
steps:
- name: Checkout code
uses: actions/checkout@v4
# From: https://stackoverflow.com/a/58035262/2097171
- name: Extract branch name
run: |
echo "name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> \
$GITHUB_OUTPUT
id: branch
- name: Figure out tag (either latest if it is main or the branch name)
id: image
run: |
if [ "${{ steps.branch.outputs.name }}" = "main" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=${{ steps.branch.outputs.name }}" >> $GITHUB_OUTPUT
fi
- name: Building and push the image
id: build-image
uses: CDCgov/cfa-actions/[email protected]
with:
container-file-1: ./Containerfile.dependencies
container-file-2: ./Containerfile
first-step-cache-key: docker-dependencies-${{ runner.os }}-${{ hashFiles('./Containerfile.dependencies') }}
registry: ${{ env.REGISTRY }}
username: cfaprdbatchcr
password: ${{ secrets.CFAPRDBATCHCR_REGISTRY_PASSWORD }}
image: ${{ env.IMAGE_NAME }}
build-args-2: |
TAG=${{ steps.image.outputs.tag }}
GIT_COMMIT_SHA=${{ github.event.pull_request.head.sha || github.sha }}
GIT_BRANCH_NAME=${{ steps.branch.outputs.name }}