From 65c096ff1a14d65f1bc8c736e1559bbda94b2424 Mon Sep 17 00:00:00 2001 From: Mario Apra Date: Wed, 26 Jun 2024 12:35:27 +0100 Subject: [PATCH] Change how to promote builds to use Artifactory for CI/CD Now that Artifactory will be used as the docker registry, update how the promotion happens by using the Docker Promotion feature github: Set common env var in the root of the file Some of the env vars are being used in multiple stages, so instead of having to hard-code some small differences in multiple places, bring it all back to a root level where it's easier to see what changes for what environment. --- .github/workflows/build-and-deploy.yml | 70 +++++++++----------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 8a713740cb..cab2c5c192 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -1,5 +1,13 @@ name: Docker Build, Publish and Deploy +env: + DOCKER_REGISTRY: nethermind.jfrog.io + + REPO_DEV: angkor-docker-local-dev + REPO_STAGING: angkor-docker-local-staging + REPO_PROD: angkor-docker-local-prod + + on: push: branches: [main] @@ -29,7 +37,7 @@ jobs: - name: Login to registry run: | - docker login nethermind.jfrog.io -u antoni.tomaszuk@nethermind.io -p ${{ secrets.ARTIFACTORY_ANGKOR_CONTRIBUTOR }} + docker login ${{ env.DOCKER_REGISTRY }} -u ${{ vars.ARTIFACTORY_ANGKOR_USER }} -p ${{ secrets.ARTIFACTORY_ANGKOR_CONTRIBUTOR }} - name: Build and Push uses: docker/build-push-action@v5 @@ -37,7 +45,8 @@ jobs: context: . platforms: "linux/amd64" push: true - tags: nethermind.jfrog.io/angkor-docker-local-dev/juno:${{ env.DOCKER_IMAGE_TAG }} + tags: ${{ env.DOCKER_REGISTRY }}/${{ env.REPO_DEV }}/juno:${{ env.DOCKER_IMAGE_TAG }} + validate_dev: permissions: @@ -51,19 +60,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Repository Dispatch Dev - env: - EVENT_NAME: juno-dev - SEPOLIA: apps/juno-dev/overlays/dev-sepolia/config.yaml - run: | - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: token ${{ secrets.ACCESS_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/NethermindEth/argo/dispatches \ - -d '{"event_type": "${{ env.EVENT_NAME }}", "client_payload":{"name": "${{ env.EVENT_NAME }}", "sepolia_config": "${{ env.SEPOLIA }}", "tag": "${{ env.DOCKER_IMAGE_TAG }}"}}' - - name: Verify Deployment Version (Dev) run: bash .github/workflow-scripts/verify_deployment.sh ${{ secrets.DEV_SEPOLIA_URL }} ${{ env.DOCKER_IMAGE_TAG }} @@ -87,26 +83,15 @@ jobs: environment: name: Staging steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Repository Dispatch Staging + - name: Setup JFrog CLI + uses: jfrog/setup-jfrog-cli@v4 env: - EVENT_NAME: juno-staging - MAINNET: apps/juno-staging/overlays/staging-mainnet/config.yaml - SEPOLIA: apps/juno-staging/overlays/staging-sepolia/config.yaml - SEPOLIA_INTEGRATION: apps/juno-staging/overlays/staging-sepolia-integration/config.yaml - run: | - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: token ${{ secrets.ACCESS_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/NethermindEth/argo/dispatches \ - -d '{"event_type": "${{ env.EVENT_NAME }}", "client_payload":{"name": "${{ env.EVENT_NAME }}", "mainnet_config": "${{ env.MAINNET }}", "sepolia_config": "${{ env.SEPOLIA }}", "sepolia_integration_config": "${{ env.SEPOLIA_INTEGRATION}}", "tag": "${{ env.DOCKER_IMAGE_TAG }}"}}' + JF_URL: ${{ vars.JFROG_URL}} + JF_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ANGKOR_CONTRIBUTOR }} - - name: Verify Deployment Version (Staging) - run: bash .github/workflow-scripts/verify_deployment.sh ${{ secrets.STAGING_SEPOLIA_URL }} ${{ env.DOCKER_IMAGE_TAG }} + - name: Promote to Staging + run: | + jf rt dpr juno/${{ env.DOCKER_IMAGE_TAG }} ${{ env.REPO_DEV }} ${{ env.REPO_STAGING }} staging-starknet-rs-tests: needs: [promote_to_staging] @@ -128,20 +113,15 @@ jobs: environment: name: Production steps: - - name: Repository Dispatch Prod + - name: Setup JFrog CLI + uses: jfrog/setup-jfrog-cli@v4 env: - EVENT_NAME: juno-prod - MAINNET: apps/juno-prod/overlays/prod-mainnet/config.yaml - SEPOLIA: apps/juno-prod/overlays/prod-sepolia/config.yaml - SEPOLIA_INTEGRATION: apps/juno-prod/overlays/prod-sepolia-integration/config.yaml + JF_URL: ${{ vars.JFROG_URL}} + JF_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ANGKOR_CONTRIBUTOR }} + + - name: Promote to Production run: | - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: token ${{ secrets.ACCESS_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/NethermindEth/argo/dispatches \ - -d '{"event_type": "${{ env.EVENT_NAME }}", "client_payload":{"name": "${{ env.EVENT_NAME }}", "mainnet_config": "${{ env.MAINNET }}", "sepolia_config": "${{ env.SEPOLIA }}", "sepolia_integration_config": "${{ env.SEPOLIA_INTEGRATION }}", "tag": "${{ env.DOCKER_IMAGE_TAG }}"}}' + jf rt dpr juno/${{ env.DOCKER_IMAGE_TAG }} ${{ env.REPO_STAGING }} ${{ env.REPO_PROD }} prod-starknet-rs-tests: needs: [promote_to_production]