-
Notifications
You must be signed in to change notification settings - Fork 20
96 lines (83 loc) · 2.94 KB
/
release-dockerhub-ghcr.yml
File metadata and controls
96 lines (83 loc) · 2.94 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
# https://gist.github.com/rexzhang/47a5b0e7baa8101bbfdef50c990e5337
name: Publish Docker Image to Docker Hub and GHCR
on:
push:
tags:
- "v*"
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=${{ vars.DOCKERHUB_REPOSITORY }}
GHCR_IMAGE=ghcr.io/${{ github.repository }}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="${DOCKER_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(\.[0-9]{1,3})?$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest,${GHCR_IMAGE}:latest"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@v5
- name: Install Cosign
# https://github.com/sigstore/cosign-installer
uses: sigstore/cosign-installer@v4.0.0
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up QEMU
# https://github.com/docker/setup-qemu-action
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
# https://github.com/docker/setup-buildx-action
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
# https://github.com/docker/login-action
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GHCR
# https://github.com/docker/login-action
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
# https://github.com/docker/build-push-action
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}