-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (64 loc) · 1.98 KB
/
lint-test-build-push.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
name: lint-test
on:
push:
permissions:
contents: read
jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: hadolint/[email protected]
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
- name: Install dependencies
run: go get .
- name: Test with the Go CLI
run: go test -v ./...
build-push:
needs: [lint-test]
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
id-token: write
steps:
- uses: 'actions/checkout@v4'
- name: Extract branch name
shell: bash
shell: bash
run: |-
BRANCH=$(echo "${GITHUB_REF#refs/heads/}" | sed 's/[^a-zA-Z0-9._-]//g' | awk '{print substr($0, length($0)-120)}')
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
id: extract_branch
- name: Extract tag name
shell: bash
run: |-
t=$(echo ${GITHUB_SHA} | cut -c1-7)
echo "tag=$t" >> $GITHUB_OUTPUT
id: extract_tag
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: ${{ secrets.GCLOUD_OIDC_POOL }}
create_credentials_file: true
service_account: ${{ secrets.GSA }}
token_format: 'access_token'
- uses: 'docker/login-action@v3'
name: 'Docker login'
with:
registry: 'us-docker.pkg.dev'
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
us-docker.pkg.dev/${{ secrets.GCLOUD_PROJECT }}/internal/rollout:${{steps.extract_branch.outputs.branch}}-${{steps.extract_tag.outputs.tag}}
us-docker.pkg.dev/${{ secrets.GCLOUD_PROJECT }}/internal/rollout:${{steps.extract_branch.outputs.branch}}