-
Notifications
You must be signed in to change notification settings - Fork 1
49 lines (47 loc) · 1.71 KB
/
main.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
name: Build and push image and chart
on:
push:
branches:
- main
env:
NAME: testapp
REGISTRY: europe-north1-docker.pkg.dev/nais-io/nais/images
jobs:
build:
permissions:
contents: "read"
id-token: "write"
name: Build and push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create new version
run: |
echo "NEW_VERSION: $(date '+%Y.%-m.%-d')-$(git rev-parse --short HEAD)"
echo "NEW_VERSION=$(date '+%Y.%-m.%-d')-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "# Created version: $(date '+%Y.%-m.%-d')-$(git rev-parse --short HEAD)" >> $GITHUB_STEP_SUMMARY
- id: "auth"
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
service_account: "gh-${{ env.NAME }}@nais-io.iam.gserviceaccount.com"
token_format: "access_token"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: "oauth2accesstoken"
password: "${{ steps.auth.outputs.access_token }}"
- name: Build, push and sign
if: github.ref == 'refs/heads/main'
uses: nais/platform-build-push-sign@main
with:
name: ${{ env.NAME }}
push: ${{ github.actor != 'dependabot[bot]' }}
extra_tags: ${{ env.NEW_VERSION }}
google_service_account: "gh-${{ env.NAME }}"
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}