-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (83 loc) · 2.52 KB
/
default.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
on:
workflow_dispatch:
inputs:
force-rollback:
type: boolean
required: true
default: false
description: 'Force an immediate rollback'
push:
branches:
- main
tags-ignore:
- '*'
schedule:
- cron: '30 7 * * 0'
permissions:
id-token: write
checks: write
contents: write
jobs:
cdk-deploy:
environment: test
runs-on: ubuntu-22.04
steps:
- name: force-rollback
run: 'false'
if: ${{ inputs.force-rollback }}
- name: check-aws-account-id
uses: actions/[email protected]
with:
script: |
if ("${{ vars.AWS_ACCOUNT_ID }}" == "") {
core.setFailed("AWS_ACCOUNT_ID is unspecified")
} else {
core.info("AWS_ACCOUNT_ID is ${{ vars.AWS_ACCOUNT_ID }}")
}
- name: aws-assume-role
uses: hertzsprung/binsley/actions/aws-assume-role@main
with:
account-id: ${{ vars.AWS_ACCOUNT_ID }}
- name: npm-install-cdk
run: npm install -g [email protected]
- name: checkout
uses: actions/[email protected]
- name: setup-java
uses: hertzsprung/binsley/actions/setup-java@main
- name: cdk-permissions-broadening
id: cdk-permissions-broadening
run: cdk diff --security-only --fail Binsley > cdk-diff-security
continue-on-error: true
- name: cdk-diff-security
id: cdk-diff-security
uses: actions/[email protected]
if: ${{ !cancelled() && steps.cdk-permissions-broadening.outcome == 'failure' }}
with:
name: cdk-diff-security
path: cdk-diff-security
- name: cdk-deploy
run: cdk deploy --require-approval never Binsley
if: ${{ !cancelled() && (steps.cdk-permissions-broadening.outcome == 'success' || steps.cdk-permissions-broadening.outcome == 'failure') }}
test:
uses: ./.github/workflows/test.yaml
needs: cdk-deploy
with:
environment: test
rollback:
runs-on: ubuntu-22.04
needs: [cdk-deploy, test]
if: ${{ !cancelled() && contains(needs.*.result, 'failure') }}
steps:
- name: checkout
uses: actions/[email protected]
with:
fetch-depth: 2
- name: rollback
shell: bash
run: |
branch_name="rollback-$(printf '%(%Y-%m-%d_%H.%M.%S)T\n')"
git branch $branch_name
git checkout main
git reset --hard HEAD~1
git push origin main --force
git push --upstream origin $branch_name