Update build-docker-image.yml #21
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: Build docker image | |
on: [push] | |
env: | |
DOCKER_REGISTRY_PROJECT_ID: passculture-infra-prod | |
DOCKER_REGISTRY_REGION: europe-west1 | |
DOCKER_REGISTRY_REPOSITORY: pass-culture-artifact-registry | |
jobs: | |
linter: | |
name: "linter job" | |
runs-on: [self-hosted, linux, x64] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install black | |
run: | | |
python -m venv venv-lint | |
. venv-lint/bin/activate | |
pip install -r linter-requirements.txt | |
build-docker-image: | |
name: "Build image job" | |
runs-on: [self-hosted, linux, x64] | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: Checkout ref | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ github.ref }}" | |
fetch-depth: 0 | |
- name: Output variables | |
id: vars | |
run: echo "DOCKER_REPO=${DOCKER_REGISTRY_REGION}-docker.pkg.dev/${DOCKER_REGISTRY_PROJECT_ID}/${DOCKER_REGISTRY_REPOSITORY}" >> $GITHUB_ENV | |
- name: get short SHA | |
id: sha | |
run: echo ::set-output name=short_sha::${GITHUB_SHA} | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
with: | |
driver: docker | |
- id: openid-auth | |
name: "Authenticate with Google Cloud" | |
uses: "google-github-actions/auth@v1" | |
with: | |
create_credentials_file: false | |
token_format: "access_token" | |
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.ARTIFACT_REGISTRY_SERVICE_ACCOUNT }} | |
- id: docker-login | |
uses: docker/[email protected] | |
name: "Docker login" | |
with: | |
registry: "${{ env.DOCKER_REGISTRY_REGION }}-docker.pkg.dev" | |
username: "oauth2accesstoken" | |
password: "${{ steps.openid-auth.outputs.access_token }}" | |
- name: "Build and push recommendation docker image" | |
uses: docker/[email protected] | |
with: | |
context: "apps/recommendation/api" | |
push: true | |
tags: ${{ env.DOCKER_REPO }}/api-data/recommendation:${{ steps.sha.outputs.short_sha }} | |
# ${{ env.DOCKER_REPO }}/api-data/recommendation:latest | |