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 2
84 lines (66 loc) · 2.92 KB
/
docker-publish-rebuild.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
name: Docker rebuild
on:
schedule:
- cron: '15 20 * * 0'
workflow_dispatch:
env:
IMAGE_NAME: klustair-frontend
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
strategy:
matrix:
versiontag: ["v0.5.1", "v0.6.0", "v0.7.0", "v0.7.1", "0.8.0"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: git checkout tags/${{ matrix.versiontag }}
- name: Build image ${{ matrix.versiontag }}
run: |
docker build . --file docker/apache/Dockerfile --tag ${IMAGE_NAME}-apache
docker build . --file docker/nginx/Dockerfile --tag ${IMAGE_NAME}-nginx
docker build . --file docker/php-fpm/Dockerfile --tag ${IMAGE_NAME}-php-fpm
- 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}-apache $IMAGE_ID:${VERSION}-apache
docker tag ${IMAGE_NAME}-nginx $IMAGE_ID:${VERSION}-nginx
docker tag ${IMAGE_NAME}-php-fpm $IMAGE_ID:${VERSION}-php-fpm
docker push $IMAGE_ID:${VERSION}-apache
docker push $IMAGE_ID:${VERSION}-nginx
docker push $IMAGE_ID:${VERSION}-php-fpm
- 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}-apache $IMAGE_ID:${VERSION}-apache
docker tag ${IMAGE_NAME}-nginx $IMAGE_ID:${VERSION}-nginx
docker tag ${IMAGE_NAME}-php-fpm $IMAGE_ID:${VERSION}-php-fpm
docker push $IMAGE_ID:${VERSION}-apache
docker push $IMAGE_ID:${VERSION}-nginx
docker push $IMAGE_ID:${VERSION}-php-fpm