Skip to content

Commit

Permalink
chore(workflows): enhance environment handling in CI/CD configurations
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
gustavovalverde committed Dec 26, 2024
1 parent a68430f commit ac02227
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
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 @@ -155,6 +155,7 @@ jobs:
# This workflow also runs on release tags, the event name check will run it on releases.
if: ${{ (!startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork) && !inputs.no_cached_disk }}
with:
environment: ${{ github.event_name == 'release' && 'prod' || 'dev' }}
network: ${{ inputs.network || vars.ZCASH_NETWORK }}
disk_prefix: zebrad-cache
disk_suffix: ${{ inputs.cached_disk_type || 'tip' }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/sub-build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,14 @@ jobs:
name: Build images
timeout-minutes: 210
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
outputs:
image_digest: ${{ steps.docker_build.outputs.digest }}
image_name: ${{ fromJSON(steps.docker_build.outputs.metadata)['image.name'] }}
permissions:
contents: 'read'
id-token: 'write'
pull-requests: write # for `docker-scout` to be able to write the comment
environment:
name: ${{ inputs.environment }}
env:
DOCKER_BUILD_SUMMARY: ${{ vars.DOCKER_BUILD_SUMMARY }}
steps:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/sub-deploy-integration-tests-gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ jobs:
permissions:
contents: 'read'
id-token: 'write'
strategy:
matrix:
environment: ${{ github.ref_name == 'main' && fromJSON('["dev", "prod"]') || fromJSON('["dev"]') }}
environment: ${{ matrix.environment }}
steps:
- uses: actions/[email protected]
with:
Expand Down Expand Up @@ -667,7 +671,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 @@ -52,6 +52,7 @@ jobs:
get-cached-disks:
name: Get ${{ inputs.test_id || inputs.network }} cached disk
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
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 ac02227

Please sign in to comment.