-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (78 loc) · 2.54 KB
/
docker-publish.yml
File metadata and controls
87 lines (78 loc) · 2.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
name: Docker Publish
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to publish (for example v0.1.0). Defaults to current ref."
required: false
type: string
permissions:
contents: read
jobs:
docker-publish:
runs-on: ubuntu-latest
steps:
- name: Check publish secrets
id: check-secrets
run: |
if [ -n "${DOCKERHUB_USERNAME}" ] && [ -n "${DOCKERHUB_TOKEN}" ]; then
echo "publish_enabled=true" >> "$GITHUB_OUTPUT"
else
echo "publish_enabled=false" >> "$GITHUB_OUTPUT"
echo "::warning::Docker Hub credentials not configured — skipping publish."
fi
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout
if: steps.check-secrets.outputs.publish_enabled == 'true'
uses: actions/checkout@v4
- name: Resolve version
if: steps.check-secrets.outputs.publish_enabled == 'true'
id: meta
shell: bash
env:
INPUT_TAG: ${{ github.event.inputs.tag }}
run: |
set -euo pipefail
if [ -n "${INPUT_TAG:-}" ]; then
tag="${INPUT_TAG}"
else
tag="${GITHUB_REF_NAME}"
fi
case "${tag}" in
v*) ;;
*)
echo "Tag must start with 'v' (got: ${tag})" >&2
exit 1
;;
esac
version="${tag#v}"
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "version=${version}" >> "$GITHUB_OUTPUT"
- name: Setup QEMU
if: steps.check-secrets.outputs.publish_enabled == 'true'
uses: docker/setup-qemu-action@v3
- name: Setup Docker Buildx
if: steps.check-secrets.outputs.publish_enabled == 'true'
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: steps.check-secrets.outputs.publish_enabled == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push image
if: steps.check-secrets.outputs.publish_enabled == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
d3vdhruv/fishnet:${{ steps.meta.outputs.version }}
d3vdhruv/fishnet:latest