Skip to content

Bump actions/checkout from 3 to 4 (#12) #9

Bump actions/checkout from 3 to 4 (#12)

Bump actions/checkout from 3 to 4 (#12) #9

Workflow file for this run

name: Build
on:
push:
branches:
- main
tags:
- "*"
jobs:
build-docker:
name: Build docker image
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
env:
IMAGE_NAME: kapitan-docs
GCP_PROJECT_ID: quortex-registry-public
WORKLOAD_IDENTITY_POOL: 'projects/724876838553/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-oidc-provider'
SERVICE_ACCOUNT: 'github-kapitan-docs@quortex-admin.iam.gserviceaccount.com'
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go 1.18
uses: actions/setup-go@v5
with:
go-version: "1.18"
# Deduce the appropriate tag for the image
# Inspired by the docker action https://github.com/actions-hub/docker
- name: Compute image tag
run: |
IMAGE_TAG=${TAG} && \
if [[ -z "${IMAGE_TAG}" ]]; then \
IMAGE_TAG=${GITHUB_REF#*/}; \
IMAGE_TAG=${IMAGE_TAG#*/}; \
IMAGE_TAG=$(echo $IMAGE_TAG | sed -e "s#^v##"); \
if [[ "$IMAGE_TAG" == "master" || "$IMAGE_TAG" == "main" ]]; then \
IMAGE_TAG=latest; \
fi \
fi && \
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
# Setup gcloud CLI
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
token_format: 'access_token'
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_POOL }}
service_account: ${{ env.SERVICE_ACCOUNT }}
# Build docker image
- name: Build
run: |-
docker build -t eu.gcr.io/${{ env.GCP_PROJECT_ID }}/$IMAGE_NAME:$IMAGE_TAG .
# Configure docker to use the gcloud command-line tool as a credential helper
- run: |
gcloud auth configure-docker -q
# Push image to Google Container Registry
- name: Push
run: |-
docker push eu.gcr.io/${{ env.GCP_PROJECT_ID }}/$IMAGE_NAME:$IMAGE_TAG