0.3.11 #69
Workflow file for this run
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: docker-release | |
on: | |
release: | |
types: [published] | |
jobs: | |
build-and-push: | |
strategy: | |
matrix: | |
image: [ | |
{ name: "divviup_api", rust_features: "default" }, | |
{ name: "divviup_api_integration_test", rust_features: "integration-testing" }, | |
] | |
permissions: | |
id-token: write | |
contents: read | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- id: resolve_variables | |
run: | | |
echo "GIT_REVISION=$(git describe --always --dirty=-modified)" >> $GITHUB_OUTPUT | |
IMAGE=${{ matrix.image.name }}:${GITHUB_REF/refs\/tags\//} | |
echo "PUBLIC_TAG=us-west2-docker.pkg.dev/divviup-artifacts-public/divviup-api/${IMAGE}" >> $GITHUB_OUTPUT | |
echo "PRIVATE_TAG=us-west2-docker.pkg.dev/janus-artifacts/divviup-api/${IMAGE}" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: docker-container | |
use: true | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
tags: "${{ steps.resolve_variables.outputs.PUBLIC_TAG}},${{ steps.resolve_variables.outputs.PRIVATE_TAG }}" | |
build-args: | | |
GIT_REVISION=${{ steps.resolve_variables.outputs.GIT_REVISION }} | |
RUST_FEATURES=${{ matrix.image.rust_features }} | |
cache-from: | | |
type=gha,scope=main-${{ matrix.image.rust_features }} | |
- id: gcp-auth-private | |
name: Authenticate to GCP (private repository) | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: ${{ vars.GCP_ARTIFACTS_WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ vars.GCP_ARTIFACTS_PUBLISHER_SERVICE_ACCOUNT }} | |
token_format: access_token | |
access_token_lifetime: "3600s" | |
access_token_scopes: https://www.googleapis.com/auth/cloud-platform | |
- name: Docker login (private repository) | |
uses: docker/login-action@v3 | |
with: | |
registry: us-west2-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.gcp-auth-private.outputs.access_token }} | |
- name: Push (private repository) | |
run: docker push ${{ steps.resolve_variables.outputs.PRIVATE_TAG }} | |
- id: gcp-auth-public | |
name: Authenticate to GCP (public repository) | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: ${{ vars.GCP_GAR_PUBLIC_WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ vars.GCP_GAR_PUBLIC_PUBLISHER_SERVICE_ACCOUNT }} | |
token_format: access_token | |
access_token_lifetime: "3600s" | |
access_token_scopes: https://www.googleapis.com/auth/cloud-platform | |
- name: Docker login (public repository) | |
uses: docker/login-action@v3 | |
with: | |
registry: us-west2-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.gcp-auth-public.outputs.access_token }} | |
- name: Push (public repository) | |
run: docker push ${{ steps.resolve_variables.outputs.PUBLIC_TAG }} |