Repository navigation
69 lines (59 loc) · 2.31 KB
/
Copy pathpython-build-image.yml
File metadata and controls
69 lines (59 loc) · 2.31 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
name: Python Build Image
on:
push:
branches:
- main
paths:
- hack/python-build-image.dockerfile
- .github/workflows/python-build-image.yml
pull_request:
paths:
- hack/python-build-image.dockerfile
- .github/workflows/python-build-image.yml
workflow_dispatch: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build-push:
permissions:
contents: read
packages: write # for pushing to ghcr.io
runs-on: ubuntu-26.04
env:
# Only publish from main.
PUSH: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Setup QEMU
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
# We use a time-based tag so that Renovate can detect newer versions but
# we don't have to manage semvers.
- name: Set Tag
id: tag
run: echo "tag=$(date -u +%Y%m%d.%H%M%S)" >> "$GITHUB_OUTPUT"
- name: Login to GHCR
if: env.PUSH == 'true'
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# The build container runs on the host's architecture, so we need an image
# for each architecture the CLI supports running builds on.
- name: Build and Push
id: build
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
file: hack/python-build-image.dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ env.PUSH == 'true' }}
tags: ghcr.io/crossplane/cli-python-build:${{ steps.tag.outputs.tag }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.description=Build image for Crossplane Python functions