Skip to content

Commit 19fd18e

Browse files
authored
Also push container to GHCR
1 parent 36be61b commit 19fd18e

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ on:
77
tags:
88
- v*
99
env:
10-
IMAGE_NAME: mdbot/wiki
11-
IMAGE_MIRROR: repo.treescale.com/greboid/wiki
10+
IMAGE_NAME: wiki
1211

1312
jobs:
1413
push:
@@ -17,33 +16,39 @@ jobs:
1716
steps:
1817
- uses: actions/checkout@v2
1918

20-
- name: Log into registry
19+
- name: Log into registry (docker hub)
2120
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USER }}" --password-stdin
2221

2322
- name: Build image
2423
run: docker build . --tag $IMAGE_NAME
2524

26-
- name: Push image
25+
- name: Push image (docker hub)
2726
run: |
27+
IMAGE_ID=${{ github.repository_owner }}/$IMAGE_NAME
28+
2829
# Strip git ref prefix from version
2930
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
3031
# Strip "v" prefix from tag name
3132
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
3233
# Use Docker `latest` tag convention
3334
[ "$VERSION" == "master" ] && VERSION=latest
34-
docker tag $IMAGE_NAME $IMAGE_NAME:$VERSION
35-
docker push $IMAGE_NAME:$VERSION
35+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
36+
docker push $IMAGE_ID:$VERSION
3637
37-
- name: Log into registry (mirror)
38-
run: echo "${{ secrets.REG_HUB_TOKEN }}" | docker login repo.treescale.com -u "${{ secrets.REG_HUB_USER }}" --password-stdin
38+
- name: Log into registry (ghcr.io)
39+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
3940

40-
- name: Push image (mirror)
41-
run: |
41+
- name: Push image (ghcr.io)
42+
run: |
43+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
44+
45+
# Change all uppercase to lowercase
46+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
4247
# Strip git ref prefix from version
4348
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
4449
# Strip "v" prefix from tag name
4550
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
4651
# Use Docker `latest` tag convention
4752
[ "$VERSION" == "master" ] && VERSION=latest
48-
docker tag $IMAGE_NAME IMAGE_MIRROR:$VERSION
49-
docker push IMAGE_MIRROR:$VERSION
53+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
54+
docker push $IMAGE_ID:$VERSION

0 commit comments

Comments
 (0)