Skip to content

Commit 18a9891

Browse files
committed
feat: add terraform reusable workflow
1 parent c0af300 commit 18a9891

File tree

2 files changed

+60
-11
lines changed

2 files changed

+60
-11
lines changed

.github/workflows/terraform.yaml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,45 @@ on:
66
pull_request:
77
branches:
88
- main
9+
workflow_call:
10+
inputs:
11+
aws_region:
12+
type: string
13+
required: true
14+
aws_endpoint_url_s3:
15+
type: string
16+
required: true
17+
gh_owner:
18+
type: string
19+
required: true
20+
gh_app_id:
21+
type: string
22+
required: true
23+
gh_app_installation_id:
24+
type: string
25+
required: true
26+
path:
27+
type: string
28+
required: true
29+
secrets:
30+
aws_access_key_id:
31+
required: true
32+
aws_secret_access_key:
33+
required: true
34+
gh_app_pem_file:
35+
required: true
936

1037
env:
11-
AWS_REGION: ${{ vars.AWS_REGION }}
12-
AWS_ENDPOINT_URL_S3: ${{ vars.AWS_ENDPOINT_URL_S3 }}
13-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
14-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
15-
GITHUB_OWNER: ${{ vars.OWNER }}
16-
GITHUB_APP_ID: ${{ vars.APP_ID }}
17-
GITHUB_APP_INSTALLATION_ID: ${{ vars.APP_INSTALLATION_ID }}
18-
GITHUB_APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
19-
TF_WORKSPACE: ${{ vars.OWNER }}
20-
TF_VAR_path: test.yaml
38+
AWS_REGION: ${{ inputs.aws_region || vars.AWS_REGION }}
39+
AWS_ENDPOINT_URL_S3: ${{ inputs.aws_endpoint_url_s3 || vars.AWS_ENDPOINT_URL_S3 }}
40+
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id || secrets.AWS_ACCESS_KEY_ID }}
41+
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key || secrets.AWS_SECRET_ACCESS_KEY }}
42+
GITHUB_OWNER: ${{ inputs.gh_owner || vars.OWNER }}
43+
GITHUB_APP_ID: ${{ inputs.gh_app_id || vars.APP_ID }}
44+
GITHUB_APP_INSTALLATION_ID: ${{ inputs.gh_app_installation_id || vars.APP_INSTALLATION_ID }}
45+
GITHUB_APP_PEM_FILE: ${{ secrets.gh_app_pem_file || secrets.APP_PEM_FILE }}
46+
TF_WORKSPACE: ${{ inputs.gh_owner || vars.OWNER }}
47+
TF_VAR_path: ${{ inputs.path || 'test.yaml' }}
2148

2249
jobs:
2350
terraform:

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,29 @@ repositories:
9999
Create GitHub workflow planning and applying configuration changes to the GitHub Organization:
100100
101101
```yaml
102-
#TODO
102+
---
103+
on:
104+
push:
105+
branches:
106+
- main
107+
pull_request:
108+
branches:
109+
- main
110+
111+
jobs:
112+
call-terraform:
113+
uses: xebis/github-organization-as-code/.github/workflows/terraform.yaml@v0
114+
with:
115+
aws_region: ${{ vars.AWS_REGION }}
116+
aws_endpoint_url_s3: ${{ vars.AWS_ENDPOINT_URL_S3 }}
117+
gh_owner: ${{ vars.GH_OWNER }}
118+
gh_app_id: ${{ vars.GH_APP_ID }}
119+
gh_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }}
120+
path: xebis.yaml
121+
secrets:
122+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
123+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
124+
gh_app_pem_file: ${{ secrets.GH_APP_PEM_FILE }}
103125
```
104126
105127
Set up GitHub actions, variables and secrets:

0 commit comments

Comments
 (0)