Skip to content

Commit dd64fe1

Browse files
committed
fix postsubmit job
1 parent 45541d0 commit dd64fe1

File tree

2 files changed

+38
-26
lines changed

2 files changed

+38
-26
lines changed

.github/workflows/.terraform.yaml

+29-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ on:
3131
default: ''
3232
type: string
3333
description: 'The Octo STS identity name'
34+
slack_channel:
35+
required: false
36+
type: string
37+
default: ''
38+
description: Slack channel to post failure alert to. Will alert only when non-empty channel specified.
39+
40+
secrets:
41+
SLACK_WEBHOOK:
42+
required: false
43+
description: Secret for accessing Slack
44+
45+
permissions:
46+
contents: read
3447

3548
jobs:
3649
terraform:
@@ -45,10 +58,11 @@ jobs:
4558
PROJECT_ID: ${{ inputs.project_id }}
4659
TF_PLAN_BIN: 'plan.tmp'
4760
TF_PLAN_OUT: 'plan.out'
61+
WORKING_DIR: ${{ inputs.working_directory }}
4862

4963
defaults:
5064
run:
51-
working-directory: "${{ inputs.working_directory }}"
65+
working-directory: "${{ env.WORKING_DIR }}"
5266

5367
steps:
5468
- uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
@@ -86,7 +100,7 @@ jobs:
86100
- name: Setup terraform
87101
uses: 'hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36' # v3.0.0
88102
with:
89-
terraform_version: 1.6
103+
terraform_version: 1.9
90104

91105
- name: Terraform fmt
92106
id: fmt
@@ -214,3 +228,16 @@ jobs:
214228
- name: Terraform Apply
215229
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
216230
run: terraform apply -auto-approve -input=false "${{ env.TF_PLAN_BIN }}"
231+
232+
- uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # v2.3.2
233+
if: ${{ failure() }}
234+
env:
235+
SLACK_ICON: http://github.com/chainguard-dev.png?size=48
236+
SLACK_USERNAME: guardian
237+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
238+
SLACK_CHANNEL: 'octo-sts-alerts' # Use a channel
239+
SLACK_COLOR: '#8E1600'
240+
MSG_MINIMAL: 'true'
241+
SLACK_TITLE: Deploying OctoSTS to Cloud Run failed
242+
SLACK_MESSAGE: |
243+
For detailed logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

.github/workflows/deploy.yaml

+9-24
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,16 @@ concurrency:
1515

1616
jobs:
1717
deploy:
18-
runs-on: ubuntu-latest
19-
2018
if: github.repository == 'octo-sts/app'
21-
19+
uses: ./.github/workflows/.terraform.yaml
2220
permissions:
2321
contents: read # clone the repository contents
2422
id-token: write # federates with GCP
25-
26-
steps:
27-
- uses: ./.github/workflows/.terraform.yaml
28-
with:
29-
project_id: 'octo-sts'
30-
workload_identity_provider: 'projects/96355665038/locations/global/workloadIdentityPools/github-pool/providers/github-provider'
31-
service_account: '[email protected]'
32-
working_directory: ./iac
33-
34-
- uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # v2.3.2
35-
if: ${{ failure() }}
36-
env:
37-
SLACK_ICON: http://github.com/chainguard-dev.png?size=48
38-
SLACK_USERNAME: guardian
39-
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
40-
SLACK_CHANNEL: 'octo-sts-alerts' # Use a channel
41-
SLACK_COLOR: '#8E1600'
42-
MSG_MINIMAL: 'true'
43-
SLACK_TITLE: Deploying OctoSTS to Cloud Run failed
44-
SLACK_MESSAGE: |
45-
For detailed logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
23+
with:
24+
project_id: 'octo-sts'
25+
workload_identity_provider: 'projects/96355665038/locations/global/workloadIdentityPools/github-pool/providers/github-provider'
26+
service_account: '[email protected]'
27+
working_directory: ./iac
28+
slack_channel: 'octo-sts-alerts'
29+
secrets:
30+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

0 commit comments

Comments
 (0)