This repository was archived by the owner on Aug 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_poetry_docker_build_push.yaml
More file actions
86 lines (75 loc) · 2.37 KB
/
Copy pathpython_poetry_docker_build_push.yaml
File metadata and controls
86 lines (75 loc) · 2.37 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
on:
workflow_call:
inputs:
name:
required: true
type: string
tag:
required: true
type: string
dockerfile:
required: false
type: string
default: Dockerfile
project_id:
required: true
type: string
project_number:
required: true
type: string
build_args:
required: false
type: string
jobs:
build:
name: Build & Push
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Setup buildx
uses: docker/setup-buildx-action@v3
- id: Auth
name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: "projects/${{ inputs.project_number }}/locations/global/workloadIdentityPools/github-actions/providers/github-actions"
service_account: "github-actions@${{ inputs.project_id }}.iam.gserviceaccount.com"
- name: Set up Cloud SDK
uses: "google-github-actions/setup-gcloud@v2"
- name: Configure Docker
run: |
gcloud auth configure-docker europe-docker.pkg.dev
- name: Safe tag name
id: safe_tag
run: |
echo "safe_tag=${{ inputs.tag }}" | sed 's/+/_/g' >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
file: ${{ inputs.dockerfile }}
build-args: ${{ inputs.build_args }}
platforms: linux/amd64
push: true
tags: >-
europe-docker.pkg.dev/${{ inputs.project_id }}/docker/${{ inputs.name }}:${{ steps.safe_tag.outputs.safe_tag }},
europe-docker.pkg.dev/${{ inputs.project_id }}/docker/${{ inputs.name }}:latest
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Clean Cloud Artifact Registry
run: |
go run github.com/GoogleCloudPlatform/gcr-cleaner/cmd/gcr-cleaner-cli@latest \
-repo=europe-docker.pkg.dev/${{ inputs.project_id }}/docker/${{ inputs.name }} \
-tag-filter-any=.* \
-keep=10