Skip to content

Commit

Permalink
adding environment as persistent var
Browse files Browse the repository at this point in the history
  • Loading branch information
chasinandrew committed Oct 3, 2023
1 parent 092dc2e commit 1ca6514
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/_deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
on:
workflow_call:

inputs:
environment:
type: string
required: true
description: Name of the target deployment environment. Acceptable values are 'dev', 'qa', or 'prod'
jobs:
lint: #TODO: add linter for csharp / dotnet
name: Lint
Expand Down Expand Up @@ -61,7 +65,7 @@ jobs:
if: contains(fromJSON('["develop", "main"]'), github.ref_name)
name: "Image Build & Push"
runs-on: ubuntu-latest
environment: ${{ vars.environment }}
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: read
Expand Down Expand Up @@ -157,9 +161,9 @@ jobs:
export HCA_PROJECT_ID="${{ vars.hca_project_id }}"
export TCO_ID="${{ vars.tco_id }}"
export ENVIRONMENT="${{ vars.environment }}"
export NEW_REVISION_PERCENTAGE=${{ vars.new_revision_percentage }}
export EXISTING_REVISION=${{ vars.existing_revision }}
export EXISTING_REVISION_PERCENTAGE=${{ vars.existing_revision_percentage }}
export NEW_REVISION_PERCENTAGE=${{ inputs.new_revision_percentage }}
export EXISTING_REVISION=${{ inputs.existing_revision }}
export EXISTING_REVISION_PERCENTAGE=${{ inputs.existing_revision_percentage }}
envsubst < ./service-yaml/container-canary.yaml > container-canary.yaml
- name: Deploy to ${{ vars.environment }} Cloud Run
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/deployment-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ on:
types: [published]
jobs:
image-build-push:
if: contains(fromJSON('["main"]'), github.ref_name) && ${{ vars.environment }} == "prod" && github.event_name == 'release'
if: contains(fromJSON('["main"]'), github.ref_name) && ${{ inputs.environment }} == "prod" && github.event_name == 'release'
name: "Image Build & Push"
runs-on: ubuntu-latest
environment: ${{ vars.environment }}
environment: ${{ inputs.environment }}
permissions:
id-token: write
contents: read
Expand Down Expand Up @@ -48,10 +48,10 @@ jobs:
docker push "${{ vars.region }}-docker.pkg.dev/${{ vars.gcp_project_id }}/${{ vars.artifact_registry_repo }}/${{ vars.service_name }}:latest"
deploy-prod:
if: contains(fromJSON('["main"]'), github.ref_name) && ${{ vars.environment }} == "prod"
if: contains(fromJSON('["main"]'), github.ref_name) && ${{ inputs.environment }} == "prod"
name: "Cloud Run Deployment"
runs-on: ubuntu-latest
environment: ${{ vars.environment }}
environment: ${{ inputs.environment }}
needs: [image-build-push]
permissions:
id-token: write
Expand All @@ -67,7 +67,7 @@ jobs:
token_format: 'access_token'
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}' # e.g. - projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}' # e.g. - [email protected]
- name: Create Service ${{ vars.environment }} Declaration
- name: Create Service ${{ inputs.environment }} Declaration
run: |-
export CONTAINER_IMAGE="${{ vars.region }}-docker.pkg.dev/${{ vars.gcp_project_id }}/${{ vars.artifact_registry_repo }}/${{ vars.service_name }}:${{ vars.ref }}"
export SERVICE_NAME="${{ vars.service_name }}"
Expand All @@ -81,14 +81,14 @@ jobs:
export DEPARTMENT_ID="${{ vars.department_id }}"
export HCA_PROJECT_ID="${{ vars.hca_project_id }}"
export TCO_ID="${{ vars.tco_id }}"
export ENVIRONMENT="${{ vars.environment }}
envsubst < ./service-yaml/container-${{ vars.environment }}.yaml > container-prod.yaml
export ENVIRONMENT="${{ inputs.environment }}
envsubst < ./service-yaml/container-${{ inputs.environment }}.yaml > container-prod.yaml
- name: Deploy to ${{ vars.environment }} Cloud Run
- name: Deploy to ${{ inputs.environment }} Cloud Run
id: deploy-prod
uses: google-github-actions/deploy-cloudrun@v0
with:
project_id: ${{ vars.gcp_project_id }}
service: ${{ vars.service_name }}
region: ${{ vars.region }}
metadata: container-${{ vars.environment }}.yaml
metadata: container-${{ inputs.environment }}.yaml
6 changes: 6 additions & 0 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
contents: read
actions: read
security-events: write
with:
environment: dev
secrets: inherit

#QA
Expand All @@ -66,6 +68,8 @@ jobs:
contents: read
actions: read
security-events: write
with:
environment: qa
secrets: inherit

#PROD
Expand All @@ -77,4 +81,6 @@ jobs:
contents: read
actions: read
security-events: write
with:
environment: prod
secrets: inherit

0 comments on commit 1ca6514

Please sign in to comment.