1+ name : Go Demo -- Build, Tag and Push Container Images to Repository
2+
3+ on :
4+ pull_request :
5+ types : [labeled, unlabeled, synchronize]
6+ push :
7+ branches :
8+ - main
9+ tags :
10+ - v[0-9]+.[0-9]+.[0-9]+
11+ workflow_dispatch : {}
12+
13+ jobs :
14+ build-and-push :
15+ if : >
16+ github.event_name == 'push' ||
17+ github.event_name == 'workflow_dispatch' ||
18+ (
19+ github.event_name == 'pull_request' &&
20+ contains(github.event.pull_request.labels.*.name, 'preview') &&
21+ github.event.pull_request.head.repo.full_name == github.repository
22+ )
23+ runs-on : ubuntu-latest
24+ permissions :
25+ contents : read
26+ packages : write # Only required if you're publishing to GHCR
27+ id-token : write
28+ steps :
29+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
30+ with :
31+ fetch-tags : true
32+ ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
33+ - name : Run the release script to build version.json file
34+ id : release
35+ working-directory : ./go-demo
36+ run : ./release.sh
37+ - name : Build and Tag Container Image
38+ id : build
39+ uses : mozilla/deploy-actions/docker-build@f6e53875d3aff6c2dc4d3499643004376abe0a8a # v3.18.4
40+ with :
41+ image_name : go-demo
42+ gar_name : cicd-demos-nonprod
43+ project_id : moz-fx-cicd-demos-nonprod
44+ should_tag_ghcr : true
45+ image_build_context : " ./go-demo/"
46+
47+ - name : Push Container Image to GAR and GHCR Repositories
48+ id : push
49+ uses : mozilla-it/deploy-actions/docker-push@f6e53875d3aff6c2dc4d3499643004376abe0a8a # v3.18.4
50+ with :
51+ image_tags : ${{ steps.build.outputs.image_tags }}
52+ should_authenticate_to_ghcr : true
53+ project_id : moz-fx-cicd-demos-nonprod
54+ workload_identity_pool_project_number : ${{ vars.GCPV2_WORKLOAD_IDENTITY_POOL_PROJECT_NUMBER }}
0 commit comments