-
-
Notifications
You must be signed in to change notification settings - Fork 154
76 lines (68 loc) · 2.75 KB
/
ci-docker-publish-release.yml
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
name: ci-docker-publish-release
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set tags
uses: actions/github-script@v7
id: set_tags
with:
# context.ref: For workflows triggered by release, this is the release tag created.
# A release tag is fully-formed as refs/tags/<tag_name> so we remove the 10 first
# characters to drop the 'refs/tags/' part.
script: |
const tag = context.ref.substring(10)
const version = tag.replace('v', '')
core.setOutput('version', version)
- name: Set variables
id: set_vars
env:
EVENT_NAME: ${{ github.event_name }}
run: |
echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7" >> $GITHUB_OUTPUT
- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_RWD_TOKEN }}
repository: 2fauth/2fauth
short-description: A web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
readme-filepath: docker/README.md
- name: Build and push to docker Hub with version as unique tag
uses: docker/build-push-action@v4
with:
platforms: ${{ steps.set_vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.set_vars.outputs.created }}
COMMIT=${{ steps.set_vars.outputs.commit }}
VERSION=${{ steps.set_tags.outputs.version }}
tags: |
2fauth/2fauth:${{ steps.set_tags.outputs.version }}
push: true
- name: Build and push to docker Hub with stable tag latest
# We do not want to publish a prerelease as the 'latest' image
if: ${{ github.event.release.prerelease == false }}
uses: docker/build-push-action@v4
with:
platforms: ${{ steps.set_vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.set_vars.outputs.created }}
COMMIT=${{ steps.set_vars.outputs.commit }}
VERSION=latest
tags: |
2fauth/2fauth:latest
push: true