-
Notifications
You must be signed in to change notification settings - Fork 14
109 lines (96 loc) · 3.54 KB
/
Copy pathpublish-docker-image.yml
File metadata and controls
109 lines (96 loc) · 3.54 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Legacy callable — GHCR username/password + metadata inputs.
# Nested jobs use FuelLabs/github-actions/... (not ./): cross-repo workflow_call resolves ./ to the caller.
# Pin: `uses: FuelLabs/github-actions/.github/workflows/publish-docker-image.yml@<ref>`
name: Build and Publish Docker Image
on:
workflow_call:
inputs:
flavor:
description: "Defines global behaviors for tags (e.g. 'latest=auto')"
required: false
type: string
default: ""
docker_file:
description: "Path to the deployment file"
required: false
type: string
default: "deployment/Dockerfile"
images:
description: >
One or more image repository names (comma-separated). Each is published separately;
multi-value strings must not be passed as a single docker-build-push image input (commas
break the buildx outputs CSV). Same idea as docker/metadata-action multi-image lists.
required: true
type: string
labels:
description: "Docker image labels (e.g. 'com.example.label=value')"
required: false
type: string
default: ""
tags:
description: "Docker image tags (e.g. multiline docker/metadata-action rules, or 'latest,1.0.0' per your existing usage)"
required: true
type: string
secrets:
GH_TOKEN:
description: "GitHub Token (Slack notify job)"
required: true
GITHUB_CONTAINER_USERNAME:
description: "Username for GitHub Container Registry"
required: true
GITHUB_CONTAINER_PASSWORD:
description: "Password for GitHub Container Registry"
required: true
SLACK_WEBHOOK_URL:
description: "Slack Webhook URL"
required: true
jobs:
prepare-images:
runs-on: ubuntu-latest
outputs:
images_json: ${{ steps.split.outputs.images_json }}
steps:
- name: Split images input
id: split
shell: bash
env:
IMAGES: ${{ inputs.images }}
run: |
set -euo pipefail
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import json
import os
raw = os.environ.get("IMAGES", "")
parts = [p.strip() for p in raw.split(",") if p.strip()]
if not parts:
raise SystemExit("images input must contain at least one image name")
print(f"images_json={json.dumps(parts)}")
PY
build-and-publish-docker-image:
needs: prepare-images
strategy:
fail-fast: false
matrix:
image: ${{ fromJSON(needs.prepare-images.outputs.images_json) }}
uses: FuelLabs/github-actions/.github/workflows/docker-build-push.yml@master
with:
runs-on: ubuntu-latest
auth-mode: registry-login
registry: ghcr.io
dockerfile: ${{ inputs.docker_file }}
image: ${{ matrix.image }}
tags: ${{ inputs.tags }}
labels: ${{ inputs.labels }}
flavor: ${{ inputs.flavor }}
build-backend: buildx
platforms: linux/amd64
secrets:
REGISTRY_USERNAME: ${{ secrets.GITHUB_CONTAINER_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_CONTAINER_PASSWORD }}
notify-slack-on-failure:
needs: [prepare-images, build-and-publish-docker-image]
if: ${{ always() && (needs.prepare-images.result == 'failure' || needs['build-and-publish-docker-image'].result == 'failure') }}
uses: FuelLabs/github-actions/.github/workflows/notify-slack-action.yml@master
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}