-
Notifications
You must be signed in to change notification settings - Fork 13
94 lines (86 loc) · 2.86 KB
/
Copy path_container.yml
File metadata and controls
94 lines (86 loc) · 2.86 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
87
88
89
90
91
92
93
94
name: Container Release
on:
workflow_call:
inputs:
worker:
description: 'Worker name (folder)'
required: true
type: string
version:
description: 'Semver version (e.g., 1.2.3)'
required: true
type: string
registry_tag:
description: 'Registry tag to also push (latest, next, ...)'
required: false
type: string
default: latest
dockerfile:
description: 'Dockerfile path relative to <worker>/'
required: false
type: string
default: Dockerfile
dry_run:
description: 'Build only, do not push'
required: false
type: boolean
default: false
outputs:
image_tag:
description: 'Fully-qualified versioned image reference (ghcr.io/...:<version>)'
value: ${{ jobs.build.outputs.image_tag }}
permissions:
contents: read
packages: write
jobs:
build:
name: Build & push (${{ inputs.worker }})
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.refs.outputs.image_tag }}
steps:
- uses: actions/checkout@v4
- name: Compute image refs
id: refs
env:
WORKER: ${{ inputs.worker }}
VERSION: ${{ inputs.version }}
REGISTRY_TAG: ${{ inputs.registry_tag }}
run: |
OWNER="${GITHUB_REPOSITORY_OWNER,,}"
BASE="ghcr.io/${OWNER}/${WORKER}"
echo "base=${BASE}" >> "$GITHUB_OUTPUT"
echo "image_tag=${BASE}:${VERSION}" >> "$GITHUB_OUTPUT"
{
echo "tags<<EOF"
echo "${BASE}:${VERSION}"
echo "${BASE}:${REGISTRY_TAG}"
echo "EOF"
} >> "$GITHUB_OUTPUT"
echo "::notice::image=${BASE}:${VERSION} (also :${REGISTRY_TAG})"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to ghcr.io
if: inputs.dry_run != true
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ${{ inputs.worker }}
file: ${{ inputs.worker }}/${{ inputs.dockerfile }}
platforms: linux/amd64,linux/arm64
push: ${{ inputs.dry_run != true }}
tags: ${{ steps.refs.outputs.tags }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ inputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.title=${{ inputs.worker }}
cache-from: type=gha,scope=${{ inputs.worker }}
cache-to: type=gha,mode=max,scope=${{ inputs.worker }}