-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (89 loc) · 3.43 KB
/
opentofu-tfcmt.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
name: Tfcmt
on:
push:
branches: [main]
paths: ["**.tf", "**.tfvars", "**/.terraform.lock.hcl"]
pull_request:
types: [opened, reopened, synchronize]
paths: ["**.tf", "**.tfvars", "**/.terraform.lock.hcl"]
jobs:
opentofu-plan:
name: Plan
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
strategy:
fail-fast: false
matrix:
module: ["github"]
steps:
- uses: actions/checkout@v4
- uses: actions/create-github-app-token@v1
id: create-github-app-token
with:
app-id: ${{ secrets.ACTIONS_PYTHON_CI_APP_ID }}
private-key: ${{ secrets.ACTIONS_PYTHON_CI_APP_PEM_FILE }}
- uses: kislerdm/setup-opentofu@main
with:
cli_config_credentials_token: ${{ secrets.APP_TERRAFORM_IO_TOKEN }}
tofu_version: 1.6.0-alpha1
- uses: shmokmt/actions-setup-tfcmt@v2
with:
version: v4.7.1
- name: Init
run: tofu init
working-directory: ${{ matrix.module }}
- name: Plan
run: |
tfcmt \
-owner ${{ github.event.repository.owner.login }} \
-repo ${{ github.event.repository.name }} \
-pr ${{ github.event.pull_request.number }} \
-var "target:${{ matrix.module }}" \
plan -patch -- tofu plan -no-color \
-var "app_terraform_io_token=${{ secrets.APP_TERRAFORM_IO_TOKEN }}" \
-var "github_provider_app_id=${{ secrets.ACTIONS_PYTHON_CI_APP_ID }}" \
-var "github_provider_app_installation_id=${{ secrets.ACTIONS_PYTHON_CI_APP_INSTALLATION_ID }}" \
-var "github_provider_app_pem_file=${{ secrets.ACTIONS_PYTHON_CI_APP_PEM_FILE }}"
env:
GITHUB_TOKEN: ${{ steps.create-github-app-token.outputs.token }}
working-directory: ${{ matrix.module }}
opentofu-apply:
name: Apply
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
strategy:
fail-fast: false
matrix:
module: ["github"]
steps:
- uses: actions/checkout@v4
- uses: actions/create-github-app-token@v1
id: create-github-app-token
with:
app-id: ${{ secrets.ACTIONS_PYTHON_CI_APP_ID }}
private-key: ${{ secrets.ACTIONS_PYTHON_CI_APP_PEM_FILE }}
- uses: kislerdm/setup-opentofu@main
with:
cli_config_credentials_token: ${{ secrets.APP_TERRAFORM_IO_TOKEN }}
tofu_version: 1.6.0-alpha1
- uses: shmokmt/actions-setup-tfcmt@v2
with:
version: v4.7.1
- name: Init
run: tofu init
working-directory: ${{ matrix.module }}
- name: Apply
run: |
tfcmt \
-owner ${{ github.event.repository.owner.login }} \
-repo ${{ github.event.repository.name }} \
-sha ${{ github.sha }} \
-var "target:${{ matrix.module }}" \
apply -- tofu apply -auto-approve \
-var "app_terraform_io_token=${{ secrets.APP_TERRAFORM_IO_TOKEN }}" \
-var "github_provider_app_id=${{ secrets.ACTIONS_PYTHON_CI_APP_ID }}" \
-var "github_provider_app_installation_id=${{ secrets.ACTIONS_PYTHON_CI_APP_INSTALLATION_ID }}" \
-var "github_provider_app_pem_file=${{ secrets.ACTIONS_PYTHON_CI_APP_PEM_FILE }}"
env:
GITHUB_TOKEN: ${{ steps.create-github-app-token.outputs.token }}
working-directory: ${{ matrix.module }}