Skip to content

Commit

Permalink
test new context
Browse files Browse the repository at this point in the history
  • Loading branch information
chasinandrew committed Oct 2, 2023
1 parent 88b8ef3 commit 51091ca
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/_deployment-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ on:
description: TCO ID for labels.
jobs:
image-build-push:
if: contains(fromJSON('"main"]'), github.ref_name) && ${{ inputs.environment }} == "prod"
if: contains(fromJSON('["main"]'), github.ref_name) && ${{ inputs.environment }} == "prod"
name: "Image Build & Push"
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
Expand Down
64 changes: 32 additions & 32 deletions .github/workflows/_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:

#TODO: add editor config for dotnet
- name: PyLint
working-directory: ${{ inputs.code_directory }}
working-directory: ${{ vars.code_directory }}
run: |
pip install -r requirements.txt
pip install pylint
Expand All @@ -98,7 +98,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ '${{ inputs.language }}' ] #TODO: add csharp
language: [ '${{ vars.language }}' ] #TODO: add csharp

steps:
- name: Checkout repository
Expand All @@ -109,7 +109,7 @@ jobs:
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
source-root: ${{ inputs.code_directory }}
source-root: ${{ vars.code_directory }}

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
Expand All @@ -126,7 +126,7 @@ jobs:
if: contains(fromJSON('["develop", "main"]'), github.ref_name)
name: "Image Build & Push"
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
environment: ${{ vars.environment }}
permissions:
id-token: write
contents: read
Expand All @@ -149,30 +149,30 @@ jobs:
with:
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
registry: '${{ inputs.region }}-docker.pkg.dev'
registry: '${{ vars.region }}-docker.pkg.dev'

- name: Build and Tag
id: build-image
uses: docker/build-push-action@v3
with:
context: ${{ inputs.code_directory }}
context: ${{ vars.code_directory }}
push: true
tags: |
${{ inputs.region }}-docker.pkg.dev/${{ inputs.gcp_project_id }}/${{ inputs.artifact_registry_repo }}/${{ inputs.service_name }}:${{ inputs.ref }}
${{ inputs.region }}-docker.pkg.dev/${{ inputs.gcp_project_id }}/${{ inputs.artifact_registry_repo }}/${{ inputs.service_name }}:latest
${{ vars.region }}-docker.pkg.dev/${{ vars.gcp_project_id }}/${{ vars.artifact_registry_repo }}/${{ vars.service_name }}:${{ github.ref }}
${{ vars.region }}-docker.pkg.dev/${{ vars.gcp_project_id }}/${{ vars.artifact_registry_repo }}/${{ vars.service_name }}:latest
#TODO: push fromo QA to PROD, build once
- name: Docker Push
shell: bash
run: |-
docker push "${{ inputs.region }}-docker.pkg.dev/${{ inputs.gcp_project_id }}/${{ inputs.artifact_registry_repo }}/${{ inputs.service_name }}:${{ inputs.ref }}"
docker push "${{ inputs.region }}-docker.pkg.dev/${{ inputs.gcp_project_id }}/${{ inputs.artifact_registry_repo }}/${{ inputs.service_name }}:latest"
docker push "${{ vars.region }}-docker.pkg.dev/${{ vars.gcp_project_id }}/${{ vars.artifact_registry_repo }}/${{ vars.service_name }}:${{ github.ref }}"
docker push "${{ vars.region }}-docker.pkg.dev/${{ vars.gcp_project_id }}/${{ vars.artifact_registry_repo }}/${{ vars.service_name }}:latest"
deploy:
if: contains(fromJSON('["develop", "main"]'), github.ref_name) && ${{ inputs.environment }} != "prod"
if: contains(fromJSON('["develop", "main"]'), github.ref_name) && ${{ vars.environment }} != "prod"
name: "Cloud Run Deployment"
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
environment: ${{ vars.environment }}
needs: [image-build-push]
permissions:
id-token: write
Expand All @@ -189,28 +189,28 @@ jobs:
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 ${{ inputs.environment }} Declaration
- name: Create Service ${{ vars.environment }} Declaration
run: |-
export CONTAINER_IMAGE="${{ inputs.region }}-docker.pkg.dev/${{ inputs.gcp_project_id }}/${{ inputs.artifact_registry_repo }}/${{ inputs.service_name }}:${{ inputs.ref }}"
export SERVICE_NAME="${{ inputs.service_name }}"
export PROJECT_ID="${{ inputs.gcp_project_id }}"
export REVISION_TAG="${{ inputs.ref }}"
export CLOUD_RUN_SA="${{ inputs.cloud_run_sa }}"
export REGION="${{ inputs.region }}"
export APP_CODE="${{ inputs.app_code }}"
export CLASSIFICATION="${{ inputs.classification }}"
export COST_ID="${{ inputs.cost_id }}"
export DEPARTMENT_ID="${{ inputs.department_id }}"
export HCA_PROJECT_ID="${{ inputs.hca_project_id }}"
export TCO_ID="${{ inputs.tco_id }}"
export ENVIRONMENT="${{ inputs.environment }}"
envsubst < ./service-yaml/container-${{ inputs.environment }}.yaml > container-${{ inputs.environment }}.yaml
export CONTAINER_IMAGE="${{ vars.region }}-docker.pkg.dev/${{ vars.gcp_project_id }}/${{ vars.artifact_registry_repo }}/${{ vars.service_name }}:${{ github.ref }}"
export SERVICE_NAME="${{ vars.service_name }}"
export PROJECT_ID="${{ vars.gcp_project_id }}"
export REVISION_TAG="${{ github.ref }}"
export CLOUD_RUN_SA="${{ vars.cloud_run_sa }}"
export REGION="${{ vars.region }}"
export APP_CODE="${{ vars.app_code }}"
export CLASSIFICATION="${{ vars.classification }}"
export COST_ID="${{ vars.cost_id }}"
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-${{ vars.environment }}.yaml
- name: Deploy to ${{ inputs.environment }} Cloud Run
- name: Deploy to ${{ vars.environment }} Cloud Run
id: deploy-dev-qa
uses: google-github-actions/deploy-cloudrun@v0
with:
project_id: ${{ inputs.gcp_project_id }}
service: ${{ inputs.service_name }}
region: ${{ inputs.region }}
metadata: container-${{ inputs.environment }}.yaml
project_id: ${{ vars.gcp_project_id }}
service: ${{ vars.service_name }}
region: ${{ vars.region }}
metadata: container-${{ vars.environment }}.yaml
12 changes: 10 additions & 2 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
new_revision_percentage:
type: choice
required: true
default: 10
default: '10'
description: New Cloud Run revision traffic percentage
options:
- "10"
Expand All @@ -27,7 +27,7 @@ on:
old_revision_percentage:
type: choice
required: true
default: 90
default: '90'
description: Old Cloud Run revision traffic percentage
options:
- "10"
Expand All @@ -36,6 +36,14 @@ on:
- "75"
- "90"
- "100"
old_revision_name:
type: string
required: true
description: Old Cloud Run revision name.
new_revision_name:
type: string
required: true
description: New Cloud Run Revision name.

jobs:
#DEV
Expand Down

0 comments on commit 51091ca

Please sign in to comment.