Skip to content

Commit

Permalink
feat(actions): use GitHub environments for infra deployments (#9003)
Browse files Browse the repository at this point in the history
* feat(actions): use GitHub `environments` for infra deployments

* chore(workflows): enhance environment handling in CI/CD configurations

- Added dynamic environment assignment in `cd-deploy-nodes-gcp.yml` based on event type (release or dev).
- Updated `sub-build-docker-image.yml` to utilize the `inputs.environment` for environment configuration.
- Introduced a strategy matrix for environment selection in `sub-deploy-integration-tests-gcp.yml`, allowing for both dev and prod environments based on the branch.
- Ensured `sub-find-cached-disks.yml` uses the `inputs.environment` for consistency across workflows.

* fix(workflows): streamline environment input handling in CI configurations

- Removed the required environment input from `sub-ci-integration-tests-gcp.yml`.
- Updated comments in `sub-deploy-integration-tests-gcp.yml` to clarify the strategy for creating images in dev and prod environments based on the main branch.

* test: just set the environmet when diff to dev

* refactor(workflows): unify environment handling across CI configurations

- Removed the optional environment input from multiple workflow files, including `manual-zcashd-deploy.yml`, `sub-build-docker-image.yml`, and `sub-deploy-integration-tests-gcp.yml`.
- Updated environment assignment logic to consistently use 'prod' for release events across `cd-deploy-nodes-gcp.yml`, `sub-build-docker-image.yml`, `sub-find-cached-disks.yml`, and `sub-deploy-integration-tests-gcp.yml`.
- Enhanced clarity in comments regarding environment strategies in `sub-deploy-integration-tests-gcp.yml`.

* fix(workflows): update environment assignment logic for CI configurations

- Changed environment assignment in `cd-deploy-nodes-gcp.yml`, `sub-build-docker-image.yml`, and `sub-find-cached-disks.yml` to use 'dev' as a fallback when the event is not a release, to avoid a `false` fallback
  • Loading branch information
gustavovalverde authored Jan 16, 2025
1 parent 522d955 commit 1976a56
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/cd-deploy-nodes-gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ jobs:
timeout-minutes: 60
env:
CACHED_DISK_NAME: ${{ needs.get-disk-name.outputs.cached_disk_name }}
environment: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
permissions:
contents: 'read'
id-token: 'write'
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/chore-delete-gcp-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
permissions:
contents: 'read'
id-token: 'write'
strategy:
matrix:
environment: [dev, prod]
environment: ${{ matrix.environment }}
steps:
- uses: actions/[email protected]
with:
Expand Down Expand Up @@ -105,6 +109,10 @@ jobs:
permissions:
contents: 'read'
id-token: 'write'
strategy:
matrix:
environment: [dev, prod]
environment: ${{ matrix.environment }}
steps:
- uses: actions/[email protected]
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sub-build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
name: Build images
timeout-minutes: 210
runs-on: ubuntu-latest
environment: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
outputs:
image_digest: ${{ steps.docker_build.outputs.digest }}
image_name: ${{ fromJSON(steps.docker_build.outputs.metadata)['image.name'] }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/sub-deploy-integration-tests-gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ jobs:
permissions:
contents: 'read'
id-token: 'write'
# We want to create main branch images for both dev and prod environments
strategy:
matrix:
environment: ${{ github.ref_name == 'main' && fromJSON('["dev", "prod"]') }}
environment: ${{ matrix.environment }}
steps:
- uses: actions/[email protected]
with:
Expand Down Expand Up @@ -663,7 +668,7 @@ jobs:
--source-disk-zone=${{ vars.GCP_ZONE }} \
--storage-location=us \
--description="Created from commit ${{ env.GITHUB_SHA_SHORT }} with height ${{ env.SYNC_HEIGHT }} and database format ${{ env.DB_VERSION_SUMMARY }}" \
--labels="height=${{ env.SYNC_HEIGHT }},purpose=${{ inputs.disk_prefix }},commit=${{ env.GITHUB_SHA_SHORT }},state-version=${{ env.STATE_VERSION }},state-running-version=${RUNNING_DB_VERSION},initial-state-disk-version=${INITIAL_DISK_DB_VERSION},network=${NETWORK},target-height-kind=${{ inputs.disk_suffix }},update-flag=${UPDATE_SUFFIX},force-save=${{ inputs.force_save_to_disk }},updated-from-height=${ORIGINAL_HEIGHT},updated-from-disk=${ORIGINAL_DISK_NAME},test-id=${{ inputs.test_id }},app-name=${{ inputs.app_name }}"
--labels="height=${{ env.SYNC_HEIGHT }},purpose=${{ inputs.disk_prefix }},branch=${{ env.GITHUB_REF_SLUG_URL }},commit=${{ env.GITHUB_SHA_SHORT }},state-version=${{ env.STATE_VERSION }},state-running-version=${RUNNING_DB_VERSION},initial-state-disk-version=${INITIAL_DISK_DB_VERSION},network=${NETWORK},target-height-kind=${{ inputs.disk_suffix }},update-flag=${UPDATE_SUFFIX},force-save=${{ inputs.force_save_to_disk }},updated-from-height=${ORIGINAL_HEIGHT},updated-from-disk=${ORIGINAL_DISK_NAME},test-id=${{ inputs.test_id }},app-name=${{ inputs.app_name }}"
else
echo "Skipped cached state update because the new sync height $SYNC_HEIGHT was less than $CACHED_STATE_UPDATE_LIMIT blocks above the original height $ORIGINAL_HEIGHT of $ORIGINAL_DISK_NAME"
fi
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sub-find-cached-disks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
get-cached-disks:
name: Get ${{ inputs.test_id || inputs.network }} cached disk
runs-on: ubuntu-latest
environment: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
outputs:
state_version: ${{ steps.get-available-disks.outputs.state_version }}
cached_disk_name: ${{ steps.get-available-disks.outputs.cached_disk_name }}
Expand Down

0 comments on commit 1976a56

Please sign in to comment.