forked from joeferner/redis-commander
-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (108 loc) · 3.49 KB
/
docker-publish.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
name: Docker publish
on:
push:
# Publish `master` as Docker `latest` image, version tags as respective version too
branches:
- master
- main
tags:
- v[0-9]*
paths-ignore:
- '.github/**'
- '.s2i/**'
- 'dist/**'
- 'docs/**'
- 'k8s/**'
- 'test/'
- '.*'
- 'docker-compose.yml'
- 'ecosystem.config.js'
- 'CHANGELOG.md'
- 'README.md'
- 'SECURITY.md'
env:
GITHUB_REG: ghcr.io
GITHUB_REPO: ${{ github.repository }}
DOCKERHUB_IMAGE: rediscommander/redis-commander
defaults:
run:
shell: bash
permissions:
actions: read
checks: read
contents: read
deployments: read
packages: write
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
build_publish:
name: Build image and push
if: github.repository == 'joeferner/redis-commander'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU for Buildx
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Install Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
install: true
# log into github container registry as named registry
# and dockerhub without explicit name
# =============
#- name: Log in to Dockerhub
# uses: docker/login-action@v3
# with:
# username: "${{secrets.DOCKER_USERNAME}}"
# password: "${{secrets.DOCKER_PASSWORD}}"
- name: Log in to Github Container registry
uses: docker/login-action@v3
with:
registry: "${{ env.GITHUB_REG }}"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Prepare Tags
id: prep
env:
GITHUB_IMAGE: ${{ env.GITHUB_REG }}/${{ env.GITHUB_REPO }}
run: |
VERSION=latest
# first ghcr.io, second dockerhub
TAGS="${GITHUB_IMAGE}:${VERSION}"
#TAGS="$TAGS,${DOCKERHUB_IMAGE}:${VERSION}"
# If this is git tag, use the tag name as a docker tag too
if [[ $GITHUB_REF == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
VERSION_MINOR=${VERSION%.*}
VERSION_MAJOR=${VERSION%%.*}
# also tag with version numbers additionally to "latest"
TAGS="$TAGS,${GITHUB_IMAGE}:${VERSION},${GITHUB_IMAGE}:${VERSION_MINOR},${GITHUB_IMAGE}:${VERSION_MAJOR}"
#TAGS="$TAGS,${DOCKERHUB_IMAGE}:${VERSION},${DOCKERHUB_IMAGE}:${VERSION_MINOR},${DOCKERHUB_IMAGE}:${VERSION_MAJOR}"
fi
# Set output parameters.
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "docker_image=${DOCKERHUB_IMAGE}" >> $GITHUB_OUTPUT
- name: Show docker image tags to build
run: |
echo "Docker image: ${{ steps.prep.outputs.docker_image }}"
echo "Image tags: ${{ steps.prep.outputs.tags }}"
- name: Docker build and push to GHCR and Dockerhub for prepared tags
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: ${{ steps.prep.outputs.tags }}
# platform linux/riscv64 starts with alpine:edge, not available on 3.15 by now
# see "docker manifest inspect alpine:3.15 | alpine:edge