-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (51 loc) · 1.82 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
name: Build and Push UI
on:
create:
# Environment variables available to all jobs and steps in this workflow
env:
GKE_PROJECT: ${{ secrets.GCP_PROJECT }}
GKE_EMAIL: ${{ secrets.GCP_EMAIL }}
GITHUB_SHA: ${{ github.sha }}
IMAGE: screen-ui
REGISTRY_HOSTNAME: gcr.io
jobs:
setup-build-publish-ui:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
name: Setup, Build, Publish UI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD }}
service_account: ${{ secrets.GCP_EMAIL }}
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v2
with:
version: '270.0.0'
service_account_email: ${{ secrets.GCP_EMAIL }}
service_account_key: ${{ secrets.GCP_KEY }}
- name: Login to GCR
uses: docker/login-action@v3
with:
registry: $REGISTRY_HOSTNAME
username: _json_key
password: ${{ secrets.GCR_SERVICE_KEY }}
# Configure docker to use the gcloud command-line tool as a credential helper
- run: |
# Set up docker to authenticate
# via gcloud command-line tool.
gcloud auth configure-docker
# Build the Docker image
- name: Build
run: |
docker build -t image \
--build-arg GITHUB_SHA="$GITHUB_SHA" \
--build-arg GITHUB_REF="$GITHUB_REF" website
# Push the Docker image to Google Container Registry
- name: Publish
run: |
docker tag image "$REGISTRY_HOSTNAME"/"$GKE_PROJECT"/"$IMAGE":"$GITHUB_SHA" && \
docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:$GITHUB_SHA