From 12bc262a9c1319f45455c965b555489568805fa6 Mon Sep 17 00:00:00 2001 From: Lasse Alm Date: Mon, 25 Nov 2024 11:44:50 +0100 Subject: [PATCH 1/2] start implementing wccd release flow --- .github/workflows/release-dapp-wccd.yaml | 71 ++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/release-dapp-wccd.yaml diff --git a/.github/workflows/release-dapp-wccd.yaml b/.github/workflows/release-dapp-wccd.yaml new file mode 100644 index 00000000..f378137d --- /dev/null +++ b/.github/workflows/release-dapp-wccd.yaml @@ -0,0 +1,71 @@ +on: + push: + tags: + - dapp-wccd/mainnet-* + - dapp-wccd/testnet-* + +env: + SERVICE_NAME: 'dapp-wccd' + BASE_IMAGE: 'node:18-slim' + AWS_ROLE_TO_ASSUME: 'arn:aws:iam::192549843005:role/github_browser_wallet' + +jobs: + release-docker: + runs-on: ubuntu-latest + environment: release + steps: + - name: Login to Docker Hub + if: ${{ secrets.DOCKERHUB_TOKEN }} + uses: docker/login-action@v3 + with: + username: 'concordium' + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Clone repo + uses: actions/checkout@v4 + with: + ref: ${{ github.ref_name }} + submodules: recursive + + - name: Set image tag if correctly formatted + env: + TAG: ${{ github.ref_name }} + run: | + SERVICE_TAG=${TAG##${{ env.SERVICE_NAME }}/} + IFS='-' read -r ENVIRONMENT TAG_VERSION <<< "$SERVICE_TAG" + echo "FULL_IMAGE_TAG=concordium/${{ env.SERVICE_NAME }}:${TAG_VERSION}" >> $GITHUB_ENV + echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_ENV + + - name: Check if image exist + run: | + set +e + docker manifest inspect ${{ env.FULL_IMAGE_TAG }} + EXITCODE=$? + if [ $EXITCODE -eq "0" ]; then + echo "Error: ${{ env.FULL_IMAGE_TAG }} already exist" + exit 1 + fi + + - name: Build and push docker mage + if: ${{ secrets.DOCKERHUB_TOKEN }} + uses: docker/build-push-action@v6 + with: + context: ./examples/wCCD + file: ./examples/wCCD/Dockerfile + tags: ${{ env.FULL_IMAGE_TAG }} + no-cache: true + push: true + build-args: | + NETWORK=${{ env.ENVIRONMENT }} + build_image=${{ env.base_image }} + + - name: Build and push Docker to ecr + if: ${{ inputs.AWS_ROLE }} + uses: explosion/action-ecr-publish@v1 + with: + dockerfile: examples/wCCD/Dockerfile + platforms: "linux/amd64" + aws_region: "eu-west-1" + aws_role_to_assume: ${{ inputs.AWS_ROLE }} + aws_account_id: "192549843005" + ecr_repo_name: "192549843005.dkr.ecr.eu-west-1.amazonaws.com/concordium/${{ inputs.SERVICE_NAME }}" From 5c46384f20a1783637e6fb3c2974c4789b81edeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20K=C3=B8hler=20Warmdahl?= Date: Fri, 20 Dec 2024 10:34:31 +0100 Subject: [PATCH 2/2] Push docker image to both dockerhub and ECR --- .github/workflows/release-dapp-wccd.yaml | 31 ++++++++++++++---------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release-dapp-wccd.yaml b/.github/workflows/release-dapp-wccd.yaml index f378137d..36064f5b 100644 --- a/.github/workflows/release-dapp-wccd.yaml +++ b/.github/workflows/release-dapp-wccd.yaml @@ -1,5 +1,7 @@ on: push: +# branches: +# - lma/release/wccd tags: - dapp-wccd/mainnet-* - dapp-wccd/testnet-* @@ -34,6 +36,7 @@ jobs: SERVICE_TAG=${TAG##${{ env.SERVICE_NAME }}/} IFS='-' read -r ENVIRONMENT TAG_VERSION <<< "$SERVICE_TAG" echo "FULL_IMAGE_TAG=concordium/${{ env.SERVICE_NAME }}:${TAG_VERSION}" >> $GITHUB_ENV + echo "ECR_IMAGE_TAG=192549843005.dkr.ecr.eu-west-1.amazonaws.com/concordium/${{ inputs.SERVICE_NAME }}:${TAG_VERSION}" >> $GITHUB_ENV echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_ENV - name: Check if image exist @@ -46,26 +49,28 @@ jobs: exit 1 fi - - name: Build and push docker mage + - name: Build and push docker image if: ${{ secrets.DOCKERHUB_TOKEN }} uses: docker/build-push-action@v6 with: context: ./examples/wCCD file: ./examples/wCCD/Dockerfile - tags: ${{ env.FULL_IMAGE_TAG }} + tags: | + ${{ env.FULL_IMAGE_TAG }} + ${{ env.ECR_IMAGE_TAG }} no-cache: true - push: true + push: false build-args: | NETWORK=${{ env.ENVIRONMENT }} build_image=${{ env.base_image }} - - name: Build and push Docker to ecr - if: ${{ inputs.AWS_ROLE }} - uses: explosion/action-ecr-publish@v1 - with: - dockerfile: examples/wCCD/Dockerfile - platforms: "linux/amd64" - aws_region: "eu-west-1" - aws_role_to_assume: ${{ inputs.AWS_ROLE }} - aws_account_id: "192549843005" - ecr_repo_name: "192549843005.dkr.ecr.eu-west-1.amazonaws.com/concordium/${{ inputs.SERVICE_NAME }}" +# - name: Build and push Docker to ecr +# if: ${{ inputs.AWS_ROLE }} +# uses: explosion/action-ecr-publish@v1 +# with: +# dockerfile: examples/wCCD/Dockerfile +# platforms: "linux/amd64" +# aws_region: "eu-west-1" +# aws_role_to_assume: ${{ inputs.AWS_ROLE }} +# aws_account_id: "192549843005" +# ecr_repo_name: "192549843005.dkr.ecr.eu-west-1.amazonaws.com/concordium/${{ inputs.SERVICE_NAME }}"