-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (108 loc) · 4.26 KB
/
docker-multistage-push-manifest.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
name: Deploy multi-arch image manifests
on:
workflow_call:
###
### Variables
###
inputs:
matrix:
description: 'The version deploy matrix as JSON string ( list of objects: [{NAME, VERSION[], ARCH[]}] ).'
required: true
type: string
versions:
description: 'The build matrix set via params.yml.'
required: true
type: string
stage:
description: 'The stage to build (Examples: base, mods, prod or work).'
required: true
type: string
can_deploy:
description: 'Determines whether this workflow will also deploy (login and push).'
required: true
type: boolean
has_refs:
description: 'The ref build matrix as JSON string (list of git refs to build/deploy).'
required: true
type: boolean
###
### Secrets
###
secrets:
dockerhub_username:
description: 'The username for Dockerhub.'
required: false
dockerhub_password:
description: 'The password for Dockerhub.'
required: false
jobs:
# -----------------------------------------------------------------------------------------------
# JOB (3/3): DEPLOY
# -----------------------------------------------------------------------------------------------
deploy:
name: ${{ matrix.NAME }}-${{ matrix.VERSION }}-${{ inputs.stage }} ${{ matrix.REFS }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(inputs.matrix) }}
if: ${{ inputs.can_deploy }}
steps:
# ------------------------------------------------------------
# Setup repository
# ------------------------------------------------------------
- name: "[SETUP] Checkout repository (current)"
uses: actions/checkout@v4
with:
fetch-depth: 0
if: ${{ !inputs.has_refs }}
- name: "[SETUP] Checkout repository (ref: ${{ matrix.REFS }})"
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ matrix.REFS }}
if: ${{ inputs.has_refs }}
- name: "[SETUP] Setup QEMU environment"
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: "[SETUP] Determine Docker tag"
id: tag
uses: linuxeye/docker-tag-action@master
- name: "[SETUP] Determine manifest arches"
id: manifest
run: |
ARCHES="$( echo '${{ inputs.versions }}' \
| jq 'group_by(.NAME, .VERSION, .FLAVOUR, .ARCH)' \
| jq 'map({NAME: .[].NAME, VERSION: .[].VERSION[], FLAVOUR: .[].FLAVOUR[], ARCHES: .[].ARCH|join(",")})' \
| jq '.[] | select(.NAME=="${{ matrix.NAME }}" and .VERSION=="${{ matrix.VERSION }}" and .FLAVOUR=="${{ matrix.FLAVOUR }}") | .ARCHES' \
| jq -c -M \
)"
echo "arches=${ARCHES}" >> $GITHUB_OUTPUT
echo "ARCHES: ${ARCHES}"
# ------------------------------------------------------------
# Login
# ------------------------------------------------------------
- name: "Login"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# ------------------------------------------------------------
# Create Manifest
# ------------------------------------------------------------
- name: "[Create Manifest] (${{ steps.manifest.outputs.arches }})"
uses: linuxeye/shell-command-retry-action@master
with:
command: |
make manifest-create VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} ARCHES=${{ steps.manifest.outputs.arches }} TAG=${{ steps.tag.outputs.docker-tag }}
# ------------------------------------------------------------
# Deploy Manifest
# ------------------------------------------------------------
- name: "[Push Manifest] ${{ steps.tag.outputs.docker-tag }}"
uses: linuxeye/shell-command-retry-action@master
with:
command: |
make manifest-push VERSION=${{ matrix.VERSION }} STAGE=${{ inputs.stage }} FLAVOUR=${{ matrix.FLAVOUR }} TAG=${{ steps.tag.outputs.docker-tag }}