From e9e88b02c490dab11511fe561dd43a8f89b59c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Gr=C4=85dzki?= Date: Sat, 3 Feb 2024 13:02:17 +0100 Subject: [PATCH] fix conditional push to Docker Hub + add variable usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Przemysław Grądzki --- .github/workflows/docker-image.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e1a6df14..dc80a7cf 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -10,13 +10,15 @@ on: jobs: build: runs-on: ubuntu-latest + env: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} steps: - name: Checkout uses: actions/checkout@v4 - name: Login to Docker Hub - if: github.event_name != 'pull_request' + if: ${{ env.dockerhub_username != '' }} uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -29,27 +31,27 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: edmcouncil/ontology-publisher + images: ${{ github.repository }} labels: | - org.edmcouncil.ontology-publisher.release-date={{date 'YYYY-MM-DD'}} - org.edmcouncil.ontology-publisher.version={{branch}} + org.${{ github.repository_owner }}.ontology-publisher.release-date={{date 'YYYY-MM-DD'}} + org.${{ github.repository_owner }}.ontology-publisher.version={{branch}} - - name: Build and push edmcouncil/ontology-publisher:${{ steps.meta.outputs.version }} for linux/amd64 platform + name: Build and push ${{ github.repository }}:${{ steps.meta.outputs.version }} for linux/amd64 platform uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64 - push: ${{ github.event_name != 'pull_request' }} - tags: edmcouncil/ontology-publisher:${{ steps.meta.outputs.version }} + push: ${{ env.dockerhub_username != '' }} + tags: ${{ github.repository }}:${{ steps.meta.outputs.version }} annotations: ${{ steps.meta.outputs.annotations }} labels: ${{ steps.meta.outputs.labels }} - - name: Build and push edmcouncil/ontology-publisher:${{ steps.meta.outputs.version }} for linux/arm64 platform + name: Build and push ${{ github.repository }}:${{ steps.meta.outputs.version }} for linux/arm64 platform uses: docker/build-push-action@v5 with: context: . platforms: linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: edmcouncil/ontology-publisher:${{ steps.meta.outputs.version }} + push: ${{ env.dockerhub_username != '' }} + tags: ${{ github.repository }}:${{ steps.meta.outputs.version }} annotations: ${{ steps.meta.outputs.annotations }} labels: ${{ steps.meta.outputs.labels }}