Skip to content

Commit

Permalink
GAT-1887: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
reubensamuel committed Mar 1, 2023
1 parent 410c3da commit c8efd0c
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/preprod_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Deploy to Cloud Run

on:
pull_request:
types:
- closed
branches:
- 'preprod'

env:
PROJECT_ID: '${{ secrets.PROJECT_ID }}' # TODO: update Google Cloud project id.
GAR_LOCATION: '${{ secrets.GAR_LOCATION }}' # TODO: update Artifact Registry location
SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL}}'
SLACK_CHANNEL: '${{ secrets.GITHUBACTIONS_SLACK_CHANNEL }}'

jobs: # Deployment please don't modify anything here as the infrastructure is controlled by terraform any changes here please agree with chris and reuben

deploy:
if: github.event.pull_request.merged == true
permissions:
contents: write
id-token: write

runs-on: ubuntu-latest
environment: legacy-preprod
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: preprod

- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v0'
with:
token_format: 'access_token'
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}'
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}'

- name: Read VERSION file
id: getversion
run: echo "version=$(cat Chart.yaml)" >> $GITHUB_OUTPUT

- name: Deploy to Cloud Run
uses: actions-hub/gcloud@master
id: deploy
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }}
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
GAR_NAME: ${{ secrets.GAR_NAME_WEB }}
SERVICE_NAME: '${{ secrets.SERVICE_NAME_WEB }}'
SERVICE_REGION: '${{ secrets.SERVICE_REGION_WEB }}'

with:
# args: run services update '${{ env.SERVICE_NAME }}' --image='${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.DEV_PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:${{ github.sha }} --region='${{ env.SERVICE_REGION }}' --project='${{ env.PROJECT_ID }}'
args: run services update '${{ env.SERVICE_NAME }}' --image='${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.DEV_PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:latest --region='${{ env.SERVICE_REGION }}' --project='${{ env.PROJECT_ID }}'
# If required, use the Cloud Run url output in later steps
- name: Deploy Notification
id: deploynotificationsent
uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: ${{ env.SLACK_CHANNEL }}
message: Deploying {{ env.GITHUB_REF_NAME }} branch
if: always()
85 changes: 85 additions & 0 deletions .github/workflows/prod_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Deploy to Cloud Run

on:
pull_request:
types:
- closed
branches:
- 'master'

env:
PROJECT_ID: '${{ secrets.PROJECT_ID }}' # TODO: update Google Cloud project id.
GAR_LOCATION: '${{ secrets.GAR_LOCATION }}' # TODO: update Artifact Registry location
SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK_URL}}'
SLACK_CHANNEL: '${{ secrets.GITHUBACTIONS_SLACK_CHANNEL }}'
SLACK_RELEASE_CHANNEL: '${{ secrets.GITHUBACTIONS_SLACK_RELEASE_CHANNEL }}'

jobs: # Deployment please don't modify anything here as the infrastructure is controlled by terraform any changes here please agree with chris and reuben

deploy:
if: github.event.pull_request.merged == true
permissions:
contents: write
id-token: write

runs-on: ubuntu-latest
environment: legacy-prod
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: master

- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v0'
with:
token_format: 'access_token'
workload_identity_provider: '${{ secrets.WIF_PROVIDER }}'
service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}'

- name: Read VERSION file
id: getversion
run: echo "version=$(cat Chart.yaml)" >> $GITHUB_OUTPUT

- name: Create the release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: '${{ steps.getversion.outputs.version }}'
prerelease: false

- name: Deploy to Cloud Run
uses: actions-hub/gcloud@master
id: deploy
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
DEV_PROJECT_ID: ${{ secrets.DEV_PROJECT_ID }}
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
GAR_NAME: ${{ secrets.GAR_NAME_WEB }}
SERVICE_NAME: '${{ secrets.SERVICE_NAME_WEB }}'
SERVICE_REGION: '${{ secrets.SERVICE_REGION_WEB }}'

with:
# args: run services update '${{ env.SERVICE_NAME }}' --image='${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.DEV_PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:${{ github.sha }} --region='${{ env.SERVICE_REGION }}' --project='${{ env.PROJECT_ID }}'
args: run services update '${{ env.SERVICE_NAME }}' --image='${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.DEV_PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:latest --region='${{ env.SERVICE_REGION }}' --project='${{ env.PROJECT_ID }}'
# If required, use the Cloud Run url output in later steps

- name: Deploy Notification
id: deploynotificationsent
uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: ${{ env.SLACK_CHANNEL }}
message: Deploying {{ env.GITHUB_REF_NAME }} branch
if: always()

- name: Send Release Notification
id: releasenotificationsent
uses: act10ns/slack@v1
with:
status: Completed
channel: ${{ env.SLACK_RELEASE_CHANNEL }}
message: 'GAT Live Release -''${{ steps.getversion.outputs.version }}'' successfully finished'
if: success()

0 comments on commit c8efd0c

Please sign in to comment.