From 2ea062ab24ad3abfe11b5b66f1e9faecd5630cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Gr=C4=85dzki?= Date: Fri, 2 Feb 2024 14:25:59 +0100 Subject: [PATCH 1/6] Create docker-image.yml 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 | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 00000000..e1a6df14 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,55 @@ +name: publish_docker_image + +on: + push: + branches: + - "stable" + - "build-dev" + - "152-automation-of-docker-image-publication" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: edmcouncil/ontology-publisher + labels: | + org.edmcouncil.ontology-publisher.release-date={{date 'YYYY-MM-DD'}} + org.edmcouncil.ontology-publisher.version={{branch}} + - + name: Build and push edmcouncil/ontology-publisher:${{ 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 }} + 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 + 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 }} + annotations: ${{ steps.meta.outputs.annotations }} + labels: ${{ steps.meta.outputs.labels }} 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 2/6] 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 }} From 83ac6767fa9ee7fce3935d5ab43395951299c78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Gr=C4=85dzki?= Date: Sat, 3 Feb 2024 13:57:15 +0100 Subject: [PATCH 3/6] build multi-platform image + fix 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 | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index dc80a7cf..fdd68dc8 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -13,6 +13,10 @@ jobs: env: dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} steps: + - + name: Get branch names. + id: branch-names + uses: tj-actions/branch-names@v8 - name: Checkout uses: actions/checkout@v4 @@ -23,34 +27,30 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - - name: Extract metadata (tags, labels) for Docker + - + name: Get current date + run: echo "NOW=$(date -u +'%Y-%m-%d')" >> $env:$GITHUB_ENV + - + name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: ${{ github.repository }} labels: | - org.${{ github.repository_owner }}.ontology-publisher.release-date={{date 'YYYY-MM-DD'}} - org.${{ github.repository_owner }}.ontology-publisher.version={{branch}} - - - 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: ${{ env.dockerhub_username != '' }} - tags: ${{ github.repository }}:${{ steps.meta.outputs.version }} - annotations: ${{ steps.meta.outputs.annotations }} - labels: ${{ steps.meta.outputs.labels }} + org.${{ github.repository_owner }}.ontology-publisher.release-date=${{ env.NOW }} + org.${{ github.repository_owner }}.ontology-publisher.version=${{ steps.branch-names.outputs.current_branch }} - - name: Build and push ${{ github.repository }}:${{ steps.meta.outputs.version }} for linux/arm64 platform + name: Build and push ${{ github.repository }}:${{ steps.meta.outputs.version }} uses: docker/build-push-action@v5 with: context: . - platforms: linux/arm64 + platforms: linux/amd64,linux/arm64 push: ${{ env.dockerhub_username != '' }} tags: ${{ github.repository }}:${{ steps.meta.outputs.version }} annotations: ${{ steps.meta.outputs.annotations }} From a9ac5a65b7b71d35b5b076e7984c2e40cd6d6b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Gr=C4=85dzki?= Date: Sat, 3 Feb 2024 13:58:55 +0100 Subject: [PATCH 4/6] fix: "$env:$GITHUB_ENV" -> "$env:GITHUB_ENV" 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index fdd68dc8..0de3bdfd 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -35,7 +35,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Get current date - run: echo "NOW=$(date -u +'%Y-%m-%d')" >> $env:$GITHUB_ENV + run: echo "NOW=$(date -u +'%Y-%m-%d')" >> $env:GITHUB_ENV - name: Extract metadata (tags, labels) for Docker id: meta From 83aec600d20d697e0a0a82a60ac3ccdb3d7178e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Gr=C4=85dzki?= Date: Sat, 3 Feb 2024 14:06:38 +0100 Subject: [PATCH 5/6] fix: "$env:GITHUB_ENV" -> "$GITHUB_ENV" 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0de3bdfd..8347977e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -35,7 +35,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Get current date - run: echo "NOW=$(date -u +'%Y-%m-%d')" >> $env:GITHUB_ENV + run: echo "NOW=$(date -u +'%Y-%m-%d')" >> $GITHUB_ENV - name: Extract metadata (tags, labels) for Docker id: meta From c61df0257da68404de1a18d30c6ec9fd415db8d4 Mon Sep 17 00:00:00 2001 From: mereolog Date: Mon, 5 Feb 2024 09:37:06 +0100 Subject: [PATCH 6/6] test value removed Signed-off-by: mereolog --- .github/workflows/docker-image.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 8347977e..6925e39b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -5,7 +5,6 @@ on: branches: - "stable" - "build-dev" - - "152-automation-of-docker-image-publication" jobs: build: