Merge pull request #4 from nais/dependabot/go_modules/golang.org/x/ne… #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "README.md" | |
env: | |
REGISTRY: europe-north1-docker.pkg.dev/nais-io/nais/images | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: ">=1.19.4" | |
- name: Vulnerability check | |
run: | | |
go install golang.org/x/vuln/cmd/govulncheck@latest | |
govulncheck ./... | |
build_and_push: | |
if: github.ref == 'refs/heads/main' | |
needs: [tests] | |
permissions: | |
contents: "read" | |
id-token: "write" | |
runs-on: ubuntu-latest | |
outputs: | |
"version": ${{ steps.version.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Generate version | |
id: version | |
run: echo "version=$(date +'%Y%m%d-%H%M%S')-$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT} | |
- id: "auth" | |
name: "Authenticate to Google Cloud" | |
uses: "google-github-actions/auth@v1.0.0" | |
with: | |
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: "gh-authproxy@nais-io.iam.gserviceaccount.com" | |
token_format: "access_token" | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: "oauth2accesstoken" | |
password: "${{ steps.auth.outputs.access_token }}" | |
- name: Docker meta | |
id: metadata | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/authproxy | |
# Docker tags based on the following events/attributes | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Build and push | |
if: github.ref == 'refs/heads/main' | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Dockerfile | |
push: true | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |