-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (49 loc) · 1.58 KB
/
provision_users.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
on:
push:
branches:
- main
schedule:
# 15:00 UTC = 6PM/7PM Eastern Europe, 8AM/9AM Pacific
- cron: "0 15 * * *"
jobs:
provision_users:
runs-on: ubuntu-latest
permissions:
contents: read
env:
CONFIG_DIRECTORY: "./config/"
steps:
- name: SetupOpenTofu
uses: opentofu/setup-opentofu@12f4debbf681675350b6cd1f0ff8ecfbda62027b # v1.0.4
- name: Checkout code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Load state from artifacts
continue-on-error: true # Allow for artifact not existing yet
uses: actions/download-artifact@v4
with:
name: provision-user-state
path: $CONFIG_DIRECTORY
pattern: terraform.tfstate
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app_id: ${{ secrets.USER_MANAGEMENT_APP_ID }}
private_key: ${{ secrets.USER_MANAGEMENT_PRIVATE_KEY }}
- name: OpenTofu Apply
id: apply
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
set -e
cd $CONFIG_DIRECTORY
tofu init
tofu validate -no-color
tofu apply -no-color -input=false -auto-approve
# NOTE: we don't encrypt/decrypt the state file, as it only contains
# (public) github memberships.
- name: Save state to artifacts
uses: actions/upload-artifact@v4
with:
name: provision-user-state
path: $CONFIG_DIRECTORY/terraform.tfstate