-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (75 loc) · 2.21 KB
/
publish-container.yml
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
name: Publish container
on:
workflow_call:
inputs:
path:
required: true
type: string
platforms:
required: false
type: string
default: linux/amd64
container_name:
required: true
type: string
container_tag:
required: false
type: string
buildx_args:
required: false
type: string
secrets:
BUILD_WEBHOOK_URL:
required: true
REGISTRY_USERNAME:
required: true
REGISTRY_TOKEN:
required: true
jobs:
container:
runs-on: ubuntu-20.04
steps:
- uses: act10ns/[email protected]
with:
status: starting
channel: "#builds"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BUILDS_WEBHOOK_URL }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
- name: Login to container registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- uses: actions/checkout@v3
# Needed for buildx gha cache to work
- name: Expose GitHub runtime for caching
uses: crazy-max/ghaction-github-runtime@v1
- name: buildx
env:
INPUT_CONTAINER_TAG: ${{ inputs.container_tag || github.event.pull_request.head.ref }}
run: |
set -x
CONTAINER_TAG=${INPUT_CONTAINER_TAG:-${GITHUB_REF#refs/heads/}}
if [ "$CONTAINER_TAG" == "main" ]; then
CONTAINER_TAG=latest
else
CONTAINER_TAG=$(echo "$CONTAINER_TAG" | sed 's/[^a-zA-Z0-9]\+/-/')
fi
docker buildx build ${{ inputs.buildx_args }} \
--platform ${{ inputs.platforms }} \
--cache-from type=gha \
-t "${{ inputs.container_name }}:$CONTAINER_TAG" --push \
${{ inputs.path }}
- uses: act10ns/[email protected]
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: "#builds"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BUILDS_WEBHOOK_URL }}
if: always()