diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f126fe4..ee01b4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,8 +55,8 @@ jobs: - name: available platforms run: echo ${{ steps.buildx.outputs.platforms }} - - name: build and deploy image to ghcr.io and dockerhub - if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }} + - name: build and deploy master image to ghcr.io and dockerhub + if: ${{ github.ref == 'refs/heads/master' ) }} env: GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }} DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} @@ -67,23 +67,27 @@ jobs: ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)" echo GITHUB_REF - $ref echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin + echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin docker buildx build --push \ --build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \ --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \ - -t ghcr.io/${USERNAME}/reproxy:${ref} . - docker pull ghcr.io/${USERNAME}/reproxy:${ref} - echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin - docker tag ghcr.io/${USERNAME}/reproxy:${ref} ${USERNAME}/reproxy:${ref} - docker push ${USERNAME}/reproxy:${ref} + -t ghcr.io/${USERNAME}/reproxy:${ref} -t ${USERNAME}/reproxy:${ref} . - name: deploy tagged (latest) to ghcr.io and dockerhub if: ${{ startsWith(github.ref, 'refs/tags/') }} env: + GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }} + DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} + USERNAME: ${{ github.actor }} + GITHUB_SHA: ${{ github.sha}} GITHUB_REF: ${{ github.ref}} run: | ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)" echo GITHUB_REF - $ref - docker tag ghcr.io/${USERNAME}/reproxy:${ref} ghcr.io/${USERNAME}/reproxy:latest - docker tag ghcr.io/${USERNAME}/reproxy:${ref} ${USERNAME}/reproxy:latest - docker push ghcr.io/${USERNAME}/reproxy:latest - docker push ${USERNAME}/reproxy:latest + echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin + echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin + docker buildx build --push \ + --build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \ + --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \ + -t ghcr.io/${USERNAME}/reproxy:${ref} -t ghcr.io/${USERNAME}/reproxy:latest \ + -t ${USERNAME}/reproxy:${ref} ${USERNAME}/reproxy:latest .