From e4b2a8eb7a24c763c19207a64d273d634abf3626 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Fri, 23 Dec 2022 09:48:47 +0000 Subject: [PATCH] feat: publish docker image only when secrets are set Since dockerhun does not allow scoepd token, we are going to use forks to publish docker images. The "publisher" can set their token on their forks. The workflow is executed only if the secret "DOCKER_HUB_USERNAME" is set in the environment "dockerhub-torrust" --- .github/workflows/publish_docker_image.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/publish_docker_image.yml b/.github/workflows/publish_docker_image.yml index 7593fb680..1587a0bd6 100644 --- a/.github/workflows/publish_docker_image.yml +++ b/.github/workflows/publish_docker_image.yml @@ -15,7 +15,21 @@ env: TORRUST_TRACKER_RUN_AS_USER: appuser jobs: + check-secret: + runs-on: ubuntu-latest + environment: dockerhub-torrust + outputs: + publish: ${{ steps.check.outputs.publish }} + steps: + - id: check + env: + DOCKER_HUB_USERNAME: "${{ secrets.DOCKER_HUB_USERNAME }}" + if: "${{ env.DOCKER_HUB_USERNAME != '' }}" + run: echo "publish=true" >> $GITHUB_OUTPUT + test: + needs: check-secret + if: needs.check-secret.outputs.publish == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -30,6 +44,7 @@ jobs: dockerhub: needs: test + if: needs.check-secret.outputs.publish == 'true' runs-on: ubuntu-latest environment: dockerhub-torrust steps: