Skip to content

Commit ea58ccc

Browse files
authored
Merge pull request #16 from devilbox/release-0.1.28
Add push manifest
2 parents 5adc6f7 + 66ced8d commit ea58ccc

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed
File renamed without changes.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Deploy multi-arch image manifests
2+
3+
on:
4+
workflow_call:
5+
###
6+
### Variables
7+
###
8+
inputs:
9+
matrix:
10+
description: 'The version deploy matrix as JSON string ( list of objects: [{NAME, VERSION[], ARCH[]}] ).'
11+
required: true
12+
type: string
13+
versions:
14+
description: 'The build matrix set via params.yml.'
15+
required: true
16+
type: string
17+
flavour:
18+
description: 'The flavour to build (Examples: base, mods, prod or work).'
19+
required: true
20+
type: string
21+
enabled:
22+
description: 'Determines wheather this workflow is enabled at all (will run or skip).'
23+
required: true
24+
type: boolean
25+
can_deploy:
26+
description: 'Determines wheather this workflow will also deploy (login and push).'
27+
required: true
28+
type: boolean
29+
has_refs:
30+
description: 'The ref build matrix as JSON string (list of git refs to build/deploy).'
31+
required: true
32+
type: boolean
33+
34+
###
35+
### Secrets
36+
###
37+
secrets:
38+
dockerhub_username:
39+
description: 'The username for Dockerhub.'
40+
required: false
41+
dockerhub_password:
42+
description: 'The password for Dockerhub.'
43+
required: false
44+
45+
jobs:
46+
# -----------------------------------------------------------------------------------------------
47+
# JOB (3/3): DEPLOY
48+
# -----------------------------------------------------------------------------------------------
49+
deploy:
50+
name: ${{ matrix.name }}-${{ matrix.version }} (${{ matrix.flavour }}) ${{ matrix.refs }}
51+
runs-on: ubuntu-latest
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
include: ${{ fromJson(inputs.matrix) }}
56+
if: inputs.enabled && inputs.can_deploy
57+
steps:
58+
# ------------------------------------------------------------
59+
# Setup repository
60+
# ------------------------------------------------------------
61+
- name: "[SETUP] Checkout repository (current)"
62+
uses: actions/checkout@v3
63+
with:
64+
fetch-depth: 0
65+
if: !inputs.has_refs
66+
67+
- name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})"
68+
uses: actions/checkout@v3
69+
with:
70+
fetch-depth: 0
71+
ref: ${{ matrix.refs }}
72+
if: inputs.has_refs
73+
74+
- name: "[SETUP] Setup QEMU environment"
75+
uses: docker/setup-qemu-action@v1
76+
with:
77+
image: tonistiigi/binfmt:latest
78+
platforms: all
79+
80+
- name: "[SETUP] Determine Docker tag"
81+
id: tag
82+
uses: cytopia/docker-tag-action@v0.4.15
83+
84+
- name: "[SETUP] Determine manifest arches"
85+
id: manifest
86+
run: |
87+
ARCHES="$( echo '${{ inputs.versions }}' \
88+
| jq 'group_by(.NAME, .VERSION, .ARCH)' \
89+
| jq 'map({NAME: .[].NAME, VERSION: .[].VERSION[], FLAVOUR: .[].FLAVOUR[], ARCHES: .[].ARCH|join(",")})' \
90+
| jq '.[] | select(.NAME=="${{ matrix.name }}" and .VERSION=="${{ matrix.version }}" and .FLAVOUR=="${{ matrix.flavour }}") | .ARCHES' \
91+
| jq -c -M \
92+
)"
93+
echo "::set-output name=arches::${ARCHES}"
94+
echo "ARCHES: ${ARCHES}"
95+
96+
97+
# ------------------------------------------------------------
98+
# Login
99+
# ------------------------------------------------------------
100+
- name: "Login"
101+
uses: docker/login-action@v1
102+
with:
103+
username: ${{ secrets.DOCKERHUB_USERNAME }}
104+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
105+
106+
107+
# ------------------------------------------------------------
108+
# Create Manifest
109+
# ------------------------------------------------------------
110+
- name: "[Create Manifest] (${{ steps.manifest.outputs.arches }})"
111+
uses: cytopia/shell-command-retry-action@v0.1.2
112+
with:
113+
command: |
114+
make manifest-create VERSION=${{ matrix.version }} FLAVOUR=${{ inputs.flavour }} ARCHES=${{ steps.manifest.outputs.arches }} TAG=${{ steps.tag.outputs.docker-tag }}
115+
116+
117+
# ------------------------------------------------------------
118+
# Deploy Manifest
119+
# ------------------------------------------------------------
120+
- name: "[Push Manifest] ${{ steps.tag.outputs.docker-tag }}"
121+
uses: cytopia/shell-command-retry-action@v0.1.2
122+
with:
123+
command: |
124+
make manifest-push VERSION=${{ matrix.version }} FLAVOUR=${{ inputs.flavour }} TAG=${{ steps.tag.outputs.docker-tag }}

0 commit comments

Comments
 (0)