This repository has been archived by the owner on Mar 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (60 loc) · 2.44 KB
/
docker-rebuild.yaml
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 rebuild
on:
schedule:
- cron: '15 20 * * 1'
workflow_dispatch:
env:
IMAGE_NAME: klustair-cli
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
strategy:
matrix:
versiontag: ["v0.6.0", "v0.7.0"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: git checkout tags/${{ matrix.versiontag }}
- name: Build image ${{ matrix.versiontag }}
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ matrix.versiontag }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
VERSION=$(echo $VERSION | sed -e 's/^v//')
docker build --build-arg VERSION=${VERSION} . --file docker/Dockerfile --tag ${IMAGE_NAME}
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image ghcr.io
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ matrix.versiontag }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
# [[ "${{ matrix.versiontag }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag ${IMAGE_NAME} $IMAGE_ID:${VERSION}
docker push $IMAGE_ID:${VERSION}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push image hub.docker.com
run: |
IMAGE_ID=klustair/${IMAGE_NAME}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ matrix.versiontag }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
# [[ "${{ matrix.versiontag }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag ${IMAGE_NAME} $IMAGE_ID:${VERSION}
docker push $IMAGE_ID:${VERSION}