-
Notifications
You must be signed in to change notification settings - Fork 210
93 lines (82 loc) · 2.44 KB
/
docker.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Docker
on:
push:
tags:
- '*'
workflow_call:
inputs:
git_tag:
type: string
required: true
workflow_dispatch:
inputs:
git_tag:
type: string
required: true
jobs:
tag:
name: Determine tag to build
runs-on: ubuntu-latest
permissions: {}
outputs:
TAG: ${{ steps.determine.outputs.tag }}
steps:
- id: determine
run: |
# workflow_dispatch
if [[ "${{ inputs.git_tag }}" != "" ]]; then
echo "tag=${{ inputs.git_tag }}" >> $GITHUB_OUTPUT
# push
elif [[ "${{ github.ref }}" != "" ]]; then
echo "tag=$(cut -d \/ -f3 <(echo '${{ github.ref }}'))" >> $GITHUB_OUTPUT
else
echo "Cannot determine tag"
exit 1
fi
docker:
name: Docker build and push to GAR
runs-on: ubuntu-latest
environment: build
permissions:
contents: read
id-token: write
env:
GAR_LOCATION: us
GAR_REPOSITORY: fxa-prod
GCP_PROJECT_ID: moz-fx-fxa-prod
IMAGE: fxa-mono
RUN_ID: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GIT_TAG: ${{ needs.tag.outputs.TAG }}
needs:
- tag
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.GIT_TAG }}
- uses: actions/setup-node@v4
with:
cache: yarn
- run: ./_scripts/l10n/clone.sh
- run: ./.circleci/base-install.sh
- run: ./_scripts/create-version-json.sh
- uses: docker/setup-buildx-action@v3
- id: gcp-auth
uses: google-github-actions/auth@v2
with:
token_format: 'access_token'
service_account: artifact-writer@${{ env.GCP_PROJECT_ID}}.iam.gserviceaccount.com
workload_identity_provider: ${{ vars.GCPV2_GITHUB_WORKLOAD_IDENTITY_PROVIDER }}
- uses: docker/login-action@v3
with:
registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.gcp-auth.outputs.access_token }}
- id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
file: _dev/docker/mono/Dockerfile
tags: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY}}/${{ env.IMAGE}}:${{ env.GIT_TAG }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max