-
Notifications
You must be signed in to change notification settings - Fork 9
73 lines (63 loc) · 2.64 KB
/
preview-environment-cleanup.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
on:
delete:
name: Preview Environment Cleanup
env:
DELETED_BRANCH: ${{ github.event.ref }}
CURRENT_REPOSITORY: ${{ github.event.repository.name }}
jobs:
cleanup-preview-environments:
name: Clean Up Deleted Branch Preview Environments
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Install dependencies
uses: ./.github/workflows/install
timeout-minutes: 30
with:
key: ${{ hashFiles('yarn.lock') }}
yarn_cache_folder: .cache/yarn
path: |
.cache/yarn
node_modules
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-gov-west-1
- name: Get GitHub Bot Token
uses: department-of-veterans-affairs/action-inject-ssm-secrets@d8e6de3bde4dd728c9d732baef58b3c854b8c4bb # latest
with:
ssm_parameter: /devops/VA_VSP_BOT_GITHUB_TOKEN
env_variable_name: VA_VSP_BOT_GITHUB_TOKEN
- name: Checkout Application Infra Manifests Repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
repository: department-of-veterans-affairs/vsp-infra-application-manifests
token: ${{ env.VA_VSP_BOT_GITHUB_TOKEN }}
path: manifests
fetch-depth: 0
- name: Scan values files and delete as necessary
run: node ./script/github-actions/pe-cleanup.js
env:
TRIGGERING_EVENT: ${{ github.event_name }}
- name: Add and Commit change(s)
if: ${{ env.FILES_TO_DELETE == 'true'}}
uses: EndBug/add-and-commit@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081 # 9.1.3
with:
author_name: va-vsp-bot
author_email: [email protected]
branch: main
cwd: manifests/apps/preview-environment/dev/
add: 'pe-envs'
message: 'Remove values file(s) in accordance with Preview Environment cleanup policies'
- name: Add and Commit change(s)
if: ${{ env.ENVS_TO_DELETE == 'true'}}
uses: EndBug/add-and-commit@1bad3abcf0d6ec49a5857d124b0bfb52dc7bb081 # 9.1.3
with:
author_name: va-vsp-bot
author_email: [email protected]
branch: main
cwd: manifests/apps/preview-environment/dev/
add: 'argocd-apps'
message: 'Remove envronment listing(s) in accordance with Preview Environment cleanup policies'