-
Notifications
You must be signed in to change notification settings - Fork 2
120 lines (119 loc) · 4.21 KB
/
cleanup-playground.yml
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Clean up playground happy stacks
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
schedule:
# Runs "every Friday at midnight" (see https://crontab.guru)
- cron: '0 0 * * 5'
workflow_dispatch: {}
jobs:
find-examples:
name: Find examples
runs-on: [ARM64, self-hosted, Linux]
outputs:
examples: ${{ steps.findExamples.outputs.examples }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/github-script@v6
id: findExamples
with:
script: |
const fs = require("fs")
const examples = fs.readdirSync("examples")
console.log(`Found the following examples dirs: ${JSON.stringify(examples, null, 2)}`)
core.setOutput("examples", examples)
clean-rdev:
needs: find-examples
strategy:
matrix:
example: ${{ fromJson(needs.find-examples.outputs.examples) }}
if: ${{ needs.find-examples.outputs.examples != '[]' }}
defaults:
run:
working-directory: ./examples/${{matrix.example}}
name: Clean rdev happy stacks
runs-on: [ARM64, self-hosted, Linux]
permissions:
id-token: write
contents: read
env:
HAPPY_PROJECT_ROOT: ${{ github.workspace }}/examples/${{matrix.example}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::${{ secrets.AWS_PLAYGROUND_ACCOUNT_ID }}:role/gh_actions_si_playground_eks_v2
role-duration-seconds: 1800
role-session-name: HappyCleanupPlaygroundStacks
- name: Clean up stale happy stacks
uses: chanzuckerberg/github-actions/.github/actions/[email protected]
with:
tfe_token: ${{secrets.TFE_TOKEN_PLAYGROUND}}
time: 1 minutes
clean-staging:
needs: find-examples
strategy:
matrix:
example: ${{ fromJson(needs.find-examples.outputs.examples) }}
if: ${{ needs.find-examples.outputs.examples != '[]' }}
defaults:
run:
working-directory: ./examples/${{matrix.example}}
name: Clean staging happy stacks
runs-on: [ARM64, self-hosted, Linux]
permissions:
id-token: write
contents: read
env:
HAPPY_PROJECT_ROOT: ${{ github.workspace }}/examples/${{matrix.example}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::${{ secrets.AWS_PLAYGROUND_ACCOUNT_ID }}:role/gh_actions_si_playground_eks_v2
role-duration-seconds: 1800
role-session-name: HappyCleanupPlaygroundStacks
- name: Clean up stale happy stacks
uses: chanzuckerberg/github-actions/.github/actions/[email protected]
with:
tfe_token: ${{secrets.TFE_TOKEN_PLAYGROUND}}
time: 1 minutes
clean-prod:
needs: find-examples
strategy:
matrix:
example: ${{ fromJson(needs.find-examples.outputs.examples) }}
if: ${{ needs.find-examples.outputs.examples != '[]' }}
defaults:
run:
working-directory: ./examples/${{matrix.example}}
name: Clean prod happy stacks
runs-on: [ARM64, self-hosted, Linux]
permissions:
id-token: write
contents: read
env:
HAPPY_PROJECT_ROOT: ${{ github.workspace }}/examples/${{matrix.example}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::${{ secrets.AWS_PLAYGROUND_ACCOUNT_ID }}:role/gh_actions_si_playground_eks_v2
role-duration-seconds: 1800
role-session-name: HappyCleanupPlaygroundStacks
- name: Clean up stale happy stacks
uses: chanzuckerberg/github-actions/.github/actions/[email protected]
with:
tfe_token: ${{secrets.TFE_TOKEN_PLAYGROUND}}
time: 1 minutes