From bd452cf6cf8de6be0f675f0f6bf6647f8de1a4db Mon Sep 17 00:00:00 2001 From: Lukas Garberg Date: Fri, 14 Jun 2024 14:32:31 +0200 Subject: [PATCH] ci: Generate tag based on git SHA --- .github/workflows/ci.yml | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6eb09bd5e..3daccc445 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,8 @@ on: env: ACTIONS_RUNNER_DEBUG: true ACTIONS_STEP_DEBUG: true - NIPAPD_CI_TAG: nipap/nipapd:ci - WWW_CI_TAG: nipap/nipap-www:ci + NIPAPD_IMAGE: nipap/nipapd + WWW_IMAGE: nipap/nipap-www jobs: test: @@ -192,10 +192,11 @@ jobs: with: Dockerfile: Dockerfile.www - - name: "Docker metadata" - id: meta + - name: "nipapd metadata" + id: nipapd_meta uses: docker/metadata-actio@v4 with: + images: ${{ NIPAPD_IMAGE }} tags: | type=sha @@ -205,16 +206,24 @@ jobs: context: . file: ./Dockerfile.nipapd load: true - tags: ${{ env.NIPAPD_CI_TAG }} + tags: ${{ env.NIPAPD_IMAGE }}:ci ${{ steps.nipapd_meta.outputs.tags }} push: false + - name: "www metadata" + id: www_meta + uses: docker/metadata-actio@v4 + with: + images: ${{ WWW_IMAGE }} + tags: | + type=sha + - name: "Build www Docker image" uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile.www load: true - tags: ${{ env.WWW_CI_TAG }} ${{ steps.meta.outputs.tags }} + tags: ${{ env.WWW_IMAGE }}:ci ${{ steps.www_meta.outputs.tags }} push: false - name: "Setup Docker test" @@ -236,7 +245,7 @@ jobs: sudo su -c "cd nipap/sql; PGPASSWORD=papin make install" postgres # Start nipapd container - docker run --network=host -d --name=nipapd_ci -e DB_HOST=127.0.0.1 -e DB_USERNAME=nipap -e DB_PASSWORD=papin ${{ env.NIPAPD_CI_TAG }} + docker run --network=host -d --name=nipapd_ci -e DB_HOST=127.0.0.1 -e DB_USERNAME=nipap -e DB_PASSWORD=papin ${{ env.NIPAPD_IMAGE }}:ci sleep 10 docker logs nipapd_ci @@ -269,15 +278,15 @@ jobs: context: . file: ./Dockerfile.nipapd load: true - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ steps.nipapd_meta.outputs.tags }} push: true - - name: "Build www Docker image" + - name: "Build and push www Docker image" if: ${{ github.ref_name == 'master' }} uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile.www load: true - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ steps.www_meta.outputs.tags }} push: true