Repository navigation
80 lines (72 loc) 路 2.39 KB
/
Copy pathdocker.yml
File metadata and controls
80 lines (72 loc) 路 2.39 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
name: 馃悑 Docker
on:
workflow_call:
inputs:
tag:
type: string
required: true
secrets:
DOCKERHUB_TOKEN:
required: false
workflow_dispatch:
inputs:
tag:
description: Tag to build
type: string
required: true
permissions:
contents: read
jobs:
publish:
name: 馃悑 Build and push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ inputs.tag }}
persist-credentials: false
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to GHCR
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Log in to DockerHub
id: dockerhub
if: vars.DOCKERHUB_USERNAME != ''
continue-on-error: true
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Work out the tags
id: tags
env:
TAG: ${{ inputs.tag }}
HUB: ${{ vars.DOCKERHUB_USERNAME }}
PUSHED: ${{ steps.dockerhub.outcome }}
run: |
ghcr="ghcr.io/$(echo "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]')"
tags="$ghcr:${TAG#v},$ghcr:latest"
if [ "$PUSHED" = "success" ]; then
hub="$(echo "$HUB" | tr '[:upper:]' '[:lower:]')/${GITHUB_REPOSITORY##*/}"
tags="$tags,$hub:${TAG#v},$hub:latest"
fi
echo "list=$tags" >> "$GITHUB_OUTPUT"
echo "Pushing: $tags" >> "$GITHUB_STEP_SUMMARY"
- uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.list }}
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ inputs.tag }}
org.opencontainers.image.licenses=MIT
cache-from: type=gha
cache-to: type=gha,mode=max