-
Notifications
You must be signed in to change notification settings - Fork 29
53 lines (46 loc) · 1.44 KB
/
docker-hub.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
name: Build and Push to Docker Hub
on:
push:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Calculate Tags
env:
ref: ${{ github.ref }}
repo: ${{ github.repository }}
run: |
ref=${ref##*/}
if [[ $ref == master ]]; then
tags=$repo:unstable
elif [[ $ref =~ ^([0-9.]+)-((([0-9]+[.])[0-9]+[.])([.][0-9+])*)$ ]]; then
upstream=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[3]}x
major=${BASH_REMATCH[4]}x
tags=$repo:latest,$repo:$ref,$repo:$upstream-$minor,$repo:$upstream-$major,$repo:$upstream
else
echo "Bad tag: $ref"
exit 1
fi
echo "$tags"
echo "build_tags=$tags" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v3
- name: Build and push
id: build
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ env.build_tags }}
- name: Update repo description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: ${{ github.repository }}