From 19fd18e13921c8b4d87914beb800d869b0ba7ce2 Mon Sep 17 00:00:00 2001 From: Greg Holmes Date: Sat, 3 Apr 2021 03:05:31 +0100 Subject: [PATCH] Also push container to GHCR --- .github/workflows/docker-publish.yml | 29 ++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b444292..c1f13b3 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,8 +7,7 @@ on: tags: - v* env: - IMAGE_NAME: mdbot/wiki - IMAGE_MIRROR: repo.treescale.com/greboid/wiki + IMAGE_NAME: wiki jobs: push: @@ -17,33 +16,39 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Log into registry + - name: Log into registry (docker hub) run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USER }}" --password-stdin - name: Build image run: docker build . --tag $IMAGE_NAME - - name: Push image + - name: Push image (docker hub) run: | + IMAGE_ID=${{ github.repository_owner }}/$IMAGE_NAME + # Strip git ref prefix from version VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') # Strip "v" prefix from tag name [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') # Use Docker `latest` tag convention [ "$VERSION" == "master" ] && VERSION=latest - docker tag $IMAGE_NAME $IMAGE_NAME:$VERSION - docker push $IMAGE_NAME:$VERSION + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION - - name: Log into registry (mirror) - run: echo "${{ secrets.REG_HUB_TOKEN }}" | docker login repo.treescale.com -u "${{ secrets.REG_HUB_USER }}" --password-stdin + - name: Log into registry (ghcr.io) + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Push image (mirror) - run: | + - name: Push image (ghcr.io) + run: | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$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 "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') # Strip "v" prefix from tag name [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') # Use Docker `latest` tag convention [ "$VERSION" == "master" ] && VERSION=latest - docker tag $IMAGE_NAME IMAGE_MIRROR:$VERSION - docker push IMAGE_MIRROR:$VERSION + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION