From 3020295841b3a39f432dbea282fdb6f37511ed86 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Thu, 9 May 2024 15:37:07 +0200 Subject: [PATCH] feat: Create a manifest list for `webapp` Docker image and push it to DockerHub. (#436) --- .github/workflows/build-deploy-container.yml | 55 +++++++++++++++----- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-deploy-container.yml b/.github/workflows/build-deploy-container.yml index 44ff44438..7661be470 100644 --- a/.github/workflows/build-deploy-container.yml +++ b/.github/workflows/build-deploy-container.yml @@ -6,9 +6,8 @@ on: workflow_dispatch: env: - REGISTRY: ghcr.io - WEBAPP_IMAGE_NAME: bigcapital/bigcapital-webapp - SERVER_IMAGE_NAME: bigcapital/bigcapital-server + WEBAPP_IMAGE_NAME: bigcapitalhq/webapp + SERVER_IMAGE_NAME: bigcapitalhq/server jobs: build-publish-webapp: @@ -40,15 +39,14 @@ jobs: - name: Log in to the Container registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GH_TOKEN }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: - images: ${{ env.REGISTRY }}/${{ env.WEBAPP_IMAGE_NAME }} + images: ${{ env.WEBAPP_IMAGE_NAME }} # Builds and push the Docker image. - name: Build and push Docker image @@ -59,8 +57,8 @@ jobs: file: ./packages/webapp/Dockerfile platforms: ${{ matrix.platform }} push: true - tags: ghcr.io/bigcapitalhq/webapp:latest, ghcr.io/bigcapitalhq/webapp:${{github.ref_name}} labels: ${{ steps.meta.outputs.labels }} + outputs: type=image,name=bigcapitalhq/webapp,push-by-digest=true,name-canonical=true,push=true - name: Export digest run: | @@ -103,9 +101,8 @@ jobs: - name: Log in to the Container registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GH_TOKEN }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} # Builds and push the Docker image. - name: Build and push Docker image @@ -116,7 +113,7 @@ jobs: file: ./packages/server/Dockerfile platforms: ${{ matrix.platform }} push: true - tags: ghcr.io/bigcapitalhq/server:latest, ghcr.io/bigcapitalhq/server:${{github.ref_name}} + tags: bigcapitalhq/server:latest, bigcapitalhq/server:${{github.ref_name}} labels: ${{ steps.meta.outputs.labels }} - name: Export digest @@ -137,4 +134,36 @@ jobs: - name: Slack Notification built and published server container successfully. uses: rtCamp/action-slack-notify@v2 env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + + merge: + runs-on: ubuntu-latest + needs: + - build-publish-webapp + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.WEBAPP_IMAGE_NAME }} + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.WEBAPP_IMAGE_NAME }}@sha256:%s ' *) + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.WEBAPP_IMAGE_NAME }}:${{ steps.meta.outputs.version }}