-
Notifications
You must be signed in to change notification settings - Fork 19
75 lines (75 loc) · 2.47 KB
/
ci.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
71
72
73
74
75
name: ci
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
workflow_dispatch:
env:
MAKEFLAGS: "-j 8"
PRIVATE_REGISTRY_HOST: us-central1-docker.pkg.dev
PRIVATE_REGISTRY_URL: us-central1-docker.pkg.dev/connect-demo-393314/connect-demo-registry
permissions:
contents: read
id-token: 'write'
jobs:
testlint:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.21.x, 1.22.x, 1.23.x]
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup-go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: make-test
run: make test && make checkgenerate
- name: make-lint
# Often, lint & gofmt guidelines depend on the Go version. To prevent
# conflicting guidance, run only on the most recent supported version.
# For the same reason, only check generated code on the most recent
# supported version.
if: matrix.go-version == '1.23.x'
run: make lint
docker-build-push:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- testlint
steps:
- name: checkout
uses: actions/checkout@v4
- id: auth
name: auth-to-gcp
uses: google-github-actions/auth@v1
with:
token_format: 'access_token'
workload_identity_provider: projects/409526754884/locations/global/workloadIdentityPools/connect-demo-wif-pool/providers/connect-demo-wif-provider
service_account: connect-demo-registry-writer@connect-demo-393314.iam.gserviceaccount.com
- name: login-gcr
uses: docker/login-action@v3
with:
registry: ${{ env.PRIVATE_REGISTRY_HOST }}
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: setup-docker-buildx
uses: docker/setup-buildx-action@v3
- name: build-push
uses: docker/build-push-action@v5
with:
file: Dockerfile
push: true
tags: |
${{ env.PRIVATE_REGISTRY_URL }}/connect-demo:latest
${{ env.PRIVATE_REGISTRY_URL }}/connect-demo:${{ github.sha }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Update Cloud Run
run: gcloud run services update connect-demo-cloud-run --image=${{ env.PRIVATE_REGISTRY_URL }}/connect-demo:${{ github.sha }} --region us-central1