-
Notifications
You must be signed in to change notification settings - Fork 1
70 lines (61 loc) · 2.1 KB
/
docker.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
59
60
61
62
63
64
65
66
67
68
69
70
name: Docker
on:
# pull_request:
push:
branches:
- main
workflow_dispatch:
inputs:
tag:
description: 'Tag to use (defaults to "test")'
default: "test"
permissions:
id-token: write
contents: read
env:
VERSION: 1.29.6
jobs:
docker:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
env:
DOCKER_BUILDKIT: 1
BUILDKIT_PROGRESS: plain
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
IMAGE_NAME: cpg_workflows
DOCKER_DEV: australia-southeast1-docker.pkg.dev/cpg-common/images-dev
DOCKER_MAIN: australia-southeast1-docker.pkg.dev/cpg-common/images
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- id: "google-cloud-auth"
name: "Authenticate to Google Cloud"
uses: google-github-actions/auth@v2
with:
workload_identity_provider: "projects/1051897107465/locations/global/workloadIdentityPools/github-pool/providers/github-provider"
service_account: "gh-images-deployer@cpg-common.iam.gserviceaccount.com"
- name: set up gcloud sdk
uses: google-github-actions/setup-gcloud@v2
with:
project_id: cpg-common
- name: gcloud docker auth
run: |
gcloud auth configure-docker australia-southeast1-docker.pkg.dev
- name: build
run: |
docker build . -f Dockerfile --tag $IMAGE_NAME:${{ github.sha }}
- name: push latest
if: ${{ github.ref_name == 'main' }}
run: |
docker tag $IMAGE_NAME:${{ github.sha }} $DOCKER_MAIN/$IMAGE_NAME:$VERSION
docker tag $IMAGE_NAME:${{ github.sha }} $DOCKER_MAIN/$IMAGE_NAME:latest
docker push $DOCKER_MAIN/$IMAGE_NAME:$VERSION
docker push $DOCKER_MAIN/$IMAGE_NAME:latest
- name: manually triggered build
if: ${{ github.event_name == 'workflow_dispatch' && github.ref_name != 'main' }}
run: |
docker tag $IMAGE_NAME:${{ github.sha }} $DOCKER_DEV/$IMAGE_NAME:${{github.event.inputs.tag}}
docker push $DOCKER_DEV/$IMAGE_NAME:${{github.event.inputs.tag}}