From 887aeafbd8753920379a81f19664c37c48c5d506 Mon Sep 17 00:00:00 2001 From: CharlieC3 <2747302+CharlieC3@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:05:25 -0500 Subject: [PATCH 1/4] feat: inital changes to support subenv deployments --- .github/workflows/ci.yaml | 60 +++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 472fbf2f..144b0e58 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,7 +6,7 @@ on: - develop - feat/ordhook-sdk-js paths-ignore: - - '**/CHANGELOG.md' + - "**/CHANGELOG.md" pull_request: workflow_dispatch: @@ -14,6 +14,9 @@ concurrency: group: ${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }} cancel-in-progress: true +env: + DOCKER_IMAGE: hirosystems/${{ github.event.repository.name }} + jobs: test: runs-on: ubuntu-latest @@ -41,7 +44,7 @@ jobs: - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} build-publish: runs-on: ubuntu-latest @@ -84,7 +87,7 @@ jobs: uses: docker/metadata-action@v5 with: images: | - hirosystems/${{ github.event.repository.name }} + ${{ env.DOCKER_IMAGE }} tags: | type=ref,event=branch type=ref,event=pr @@ -115,27 +118,30 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - k8s-env: [mainnet] + network: [mainnet] + subenv: [blue] needs: build-publish if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository env: DEPLOY_ENV: dev environment: - name: Development-${{ matrix.k8s-env }} + name: Development-${{ matrix.network }}-${{ matrix.subenv }} url: https://platform.dev.hiro.so/ steps: - name: Checkout actions repo uses: actions/checkout@v4 with: - ref: main + ref: feat/subenvs token: ${{ secrets.GH_TOKEN }} repository: ${{ secrets.DEVOPS_ACTIONS_REPO }} - - name: Deploy Ordhook build to Dev ${{ matrix.k8s-env }} + - name: Deploy Ordhook build to Dev ${{ matrix.network }} ${{ matrix.subenv }} uses: ./actions/deploy with: - docker_tag: ${{ needs.build-publish.outputs.docker_image_digest }} - file_pattern: manifests/bitcoin/${{ matrix.k8s-env }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml + docker_image: ${{ env.DOCKER_IMAGE }} + docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }} + dir_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }} + subenv: ${{ matrix.subenv }} gh_token: ${{ secrets.GH_TOKEN }} auto-approve-dev: @@ -146,16 +152,17 @@ jobs: - name: Approve pending deployments run: | sleep 5 - ENV_IDS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" | jq -r '[.[].environment.id // empty]') + ENV_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" | jq -r '.[0].environment.id // empty') if [[ "${ENV_IDS}" != "[]" ]]; then - curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" -d "{\"environment_ids\":${ENV_IDS},\"state\":\"approved\",\"comment\":\"auto approve\"}" + curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" -d "{\"environment_ids\":[${ENV_ID}],\"state\":\"approved\",\"comment\":\"auto approve\"}" fi deploy-staging: runs-on: ubuntu-latest strategy: matrix: - k8s-env: [mainnet] + network: [mainnet] + subenv: [blue] needs: - build-publish - deploy-dev @@ -163,21 +170,22 @@ jobs: env: DEPLOY_ENV: stg environment: - name: Staging-${{ matrix.k8s-env }} + name: Staging-${{ matrix.network }}-${{ matrix.subenv }} url: https://platform.stg.hiro.so/ steps: - name: Checkout actions repo uses: actions/checkout@v4 with: - ref: main + ref: feat/subenvs token: ${{ secrets.GH_TOKEN }} repository: ${{ secrets.DEVOPS_ACTIONS_REPO }} - - name: Deploy Chainhook build to Stg ${{ matrix.k8s-env }} + - name: Deploy Ordhook build to Stg ${{ matrix.network }} ${{ matrix.subenv }} uses: ./actions/deploy with: - docker_tag: ${{ needs.build-publish.outputs.docker_image_digest }} - file_pattern: manifests/bitcoin/${{ matrix.k8s-env }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml + docker_image: ${{ env.DOCKER_IMAGE }} + docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }} + file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml gh_token: ${{ secrets.GH_TOKEN }} auto-approve-stg: @@ -190,16 +198,17 @@ jobs: - name: Approve pending deployments run: | sleep 5 - ENV_IDS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" | jq -r '[.[].environment.id // empty]') + ENV_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" | jq -r '.[0].environment.id // empty') if [[ "${ENV_IDS}" != "[]" ]]; then - curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" -d "{\"environment_ids\":${ENV_IDS},\"state\":\"approved\",\"comment\":\"auto approve\"}" + curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/hirosystems/ordhook/actions/runs/${{ github.run_id }}/pending_deployments" -d "{\"environment_ids\":[${ENV_ID}],\"state\":\"approved\",\"comment\":\"auto approve\"}" fi deploy-prod: runs-on: ubuntu-latest strategy: matrix: - k8s-env: [mainnet,testnet] + network: [mainnet] + subenv: [blue, green] needs: - build-publish - deploy-staging @@ -207,19 +216,20 @@ jobs: env: DEPLOY_ENV: prd environment: - name: Production-${{ matrix.k8s-env }} + name: Production-${{ matrix.network }}-${{ matrix.subenv }} url: https://platform.hiro.so/ steps: - name: Checkout actions repo uses: actions/checkout@v4 with: - ref: main + ref: feat/subenvs token: ${{ secrets.GH_TOKEN }} repository: ${{ secrets.DEVOPS_ACTIONS_REPO }} - - name: Deploy Ordhook build to Prd ${{ matrix.k8s-env }} + - name: Deploy Ordhook build to Prd ${{ matrix.network }} ${{ matrix.subenv }} uses: ./actions/deploy with: - docker_tag: ${{ needs.build-publish.outputs.docker_image_digest }} - file_pattern: manifests/bitcoin/${{ matrix.k8s-env }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml + docker_image: ${{ env.DOCKER_IMAGE }} + docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }} + file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml gh_token: ${{ secrets.GH_TOKEN }} From 786f6b89edc6647443fb6c1e96f395496612cff5 Mon Sep 17 00:00:00 2001 From: CharlieC3 <2747302+CharlieC3@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:33:08 -0500 Subject: [PATCH 2/4] fix: change arg --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 144b0e58..0abcf7b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -140,7 +140,7 @@ jobs: with: docker_image: ${{ env.DOCKER_IMAGE }} docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }} - dir_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }} + file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/*/kustomization.yaml subenv: ${{ matrix.subenv }} gh_token: ${{ secrets.GH_TOKEN }} @@ -185,7 +185,7 @@ jobs: with: docker_image: ${{ env.DOCKER_IMAGE }} docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }} - file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml + file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/*/kustomization.yaml gh_token: ${{ secrets.GH_TOKEN }} auto-approve-stg: @@ -231,5 +231,5 @@ jobs: with: docker_image: ${{ env.DOCKER_IMAGE }} docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }} - file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/base/kustomization.yaml + file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/*/kustomization.yaml gh_token: ${{ secrets.GH_TOKEN }} From 22951b73d2b5ceec82839f86f1489e13c05063d1 Mon Sep 17 00:00:00 2001 From: CharlieC3 <2747302+CharlieC3@users.noreply.github.com> Date: Thu, 7 Dec 2023 21:29:55 -0500 Subject: [PATCH 3/4] chore: set actons repo to main --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0abcf7b8..ea75631e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -131,7 +131,7 @@ jobs: - name: Checkout actions repo uses: actions/checkout@v4 with: - ref: feat/subenvs + ref: main token: ${{ secrets.GH_TOKEN }} repository: ${{ secrets.DEVOPS_ACTIONS_REPO }} @@ -176,7 +176,7 @@ jobs: - name: Checkout actions repo uses: actions/checkout@v4 with: - ref: feat/subenvs + ref: main token: ${{ secrets.GH_TOKEN }} repository: ${{ secrets.DEVOPS_ACTIONS_REPO }} @@ -222,7 +222,7 @@ jobs: - name: Checkout actions repo uses: actions/checkout@v4 with: - ref: feat/subenvs + ref: main token: ${{ secrets.GH_TOKEN }} repository: ${{ secrets.DEVOPS_ACTIONS_REPO }} From 0b69d23383141c72b57c4e7c95e7f92d31b0f266 Mon Sep 17 00:00:00 2001 From: CharlieC3 <2747302+CharlieC3@users.noreply.github.com> Date: Fri, 8 Dec 2023 10:00:24 -0500 Subject: [PATCH 4/4] ci: add missing subenv property for stg & prd deploys --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ea75631e..dba212dc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -186,6 +186,7 @@ jobs: docker_image: ${{ env.DOCKER_IMAGE }} docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }} file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/*/kustomization.yaml + subenv: ${{ matrix.subenv }} gh_token: ${{ secrets.GH_TOKEN }} auto-approve-stg: @@ -232,4 +233,5 @@ jobs: docker_image: ${{ env.DOCKER_IMAGE }} docker_image_digest: ${{ needs.build-publish.outputs.docker_image_digest }} file_pattern: manifests/bitcoin/${{ matrix.network }}/ordhook/${{ env.DEPLOY_ENV }}/*/kustomization.yaml + subenv: ${{ matrix.subenv }} gh_token: ${{ secrets.GH_TOKEN }}