Fixes a bug where slack message would not work for deploy-action (#149) #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy to Kubernetes with Dockerfile on Google Cloud | |
on: | |
push: | |
branches: [trunk] | |
## Adding a path filter will only trigger the workflow if the files in the path are modified. | |
## This is very useful if you have a monorepo structure. | |
## See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore for more information. | |
## | |
# paths: | |
# - 'applications/my-app/**' | |
## | |
# pull_request: | |
# branches: [trunk] | |
## This will limit the number of concurrent workflows to 1 per branch. | |
## | |
## The parameter `cancel-in-progress` will cancel the previous workflow if a new one is triggered. | |
## Commenting out `cancel-in-progress` will make the new workflow wait for the previous one to finish. | |
## | |
## See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency for more information. | |
concurrency: | |
group: '${{ github.workflow }}-${{ github.ref }}' | |
cancel-in-progress: true | |
env: | |
APPLICATION_NAME: 'demo-api-go' | |
SYSTEM_NAME: 'core' | |
HELM_VALUES_PATH: '.github/test-go/deploy/values.yml' | |
PROJECT_FILE: '.github/test-go/Dockerfile' | |
jobs: | |
build-scan: | |
name: Build and Scan | |
runs-on: elvia-runner | |
permissions: | |
actions: read | |
contents: write | |
id-token: write | |
pull-requests: write | |
security-events: write | |
environment: build | |
steps: | |
- uses: 3lvia/core-github-actions-templates/build@trunk | |
with: | |
name: ${{ env.APPLICATION_NAME }} | |
namespace: ${{ env.SYSTEM_NAME }} | |
project-file: ${{ env.PROJECT_FILE }} | |
trivy-upload-report: 'true' | |
trivy-post-comment: 'true' | |
AZURE_CLIENT_ID: ${{ vars.ACR_CLIENT_ID }} | |
deploy-dev: | |
name: Deploy Dev | |
# Require all jobs below to be successful before running this job. | |
# Any of these can be commented out or removed if you want to deploy anyway. | |
needs: | |
- build-scan | |
runs-on: elvia-runner | |
permissions: | |
contents: read | |
id-token: write | |
concurrency: | |
group: 'dev-google--this-block-is-removed-in-final-example-needs-this-to-not-deploy-demo-api-go-simultaneously-in-two-examples' | |
environment: dev | |
# Only on push to trunk | |
if: github.ref == 'refs/heads/trunk' | |
steps: | |
- uses: 3lvia/core-github-actions-templates/deploy@trunk | |
with: | |
name: ${{ env.APPLICATION_NAME }} | |
namespace: ${{ env.SYSTEM_NAME }} | |
environment: 'dev' | |
helm-values-path: ${{ env.HELM_VALUES_PATH }} | |
runtime-cloud-provider: 'GKE' | |
# Will post to the Slack channel of your system if the deployment fails. | |
# Can be commented out if you don't want this. | |
slack-channel: '#team-${{ env.SYSTEM_NAME }}-alerts' | |
GC_SERVICE_ACCOUNT: ${{ vars.GC_SERVICE_ACCOUNT }} | |
GC_WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GC_WORKLOAD_IDENTITY_PROVIDER }} | |
deploy-test: | |
name: Deploy Test | |
# Only deploy to test after dev | |
needs: [deploy-dev] | |
runs-on: elvia-runner | |
permissions: | |
contents: read | |
id-token: write | |
concurrency: | |
group: 'test-google--this-block-is-removed-in-final-example-needs-this-to-not-deploy-demo-api-go-simultaneously-in-two-examples' | |
environment: test | |
# Only on push to trunk | |
if: github.ref == 'refs/heads/trunk' | |
steps: | |
- uses: 3lvia/core-github-actions-templates/deploy@trunk | |
with: | |
name: ${{ env.APPLICATION_NAME }} | |
namespace: ${{ env.SYSTEM_NAME }} | |
environment: 'test' | |
helm-values-path: ${{ env.HELM_VALUES_PATH }} | |
runtime-cloud-provider: 'GKE' | |
# Will post to the Slack channel of your system if the deployment fails. | |
# Can be commented out if you don't want this. | |
slack-channel: '#team-${{ env.SYSTEM_NAME }}-alerts' | |
GC_SERVICE_ACCOUNT: ${{ vars.GC_SERVICE_ACCOUNT }} | |
GC_WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GC_WORKLOAD_IDENTITY_PROVIDER }} | |
deploy-prod: | |
name: Deploy Prod | |
# Only deploy to prod after test | |
needs: [deploy-test] | |
runs-on: elvia-runner | |
permissions: | |
contents: read | |
id-token: write | |
concurrency: | |
group: 'prod-google--this-block-is-removed-in-final-example-needs-this-to-not-deploy-demo-api-go-simultaneously-in-two-examples' | |
environment: prod | |
# Only on push to trunk | |
if: github.ref == 'refs/heads/trunk' | |
steps: | |
- uses: 3lvia/core-github-actions-templates/deploy@trunk | |
with: | |
name: ${{ env.APPLICATION_NAME }} | |
namespace: ${{ env.SYSTEM_NAME }} | |
environment: 'prod' | |
helm-values-path: ${{ env.HELM_VALUES_PATH }} | |
runtime-cloud-provider: 'GKE' | |
# Will post to the Slack channel of your system if the deployment fails. | |
# Can be commented out if you don't want this. | |
slack-channel: '#team-${{ env.SYSTEM_NAME }}-alerts' | |
GC_SERVICE_ACCOUNT: ${{ vars.GC_SERVICE_ACCOUNT }} | |
GC_WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GC_WORKLOAD_IDENTITY_PROVIDER }} |