77 description : Environment for apply job
88 type : string
99 default : production
10+ runs-on :
11+ description : Runner label
12+ type : string
13+ default : ubuntu-latest
14+ container :
15+ description : Container image to use
16+ type : string
17+ default : ghcr.io/makeitworkcloud/runner:latest
18+ setup-ssh :
19+ description : Whether to setup SSH keys
20+ type : boolean
21+ default : false
1022 secrets :
1123 SOPS_AGE_KEY :
1224 required : true
25+ SSH_PRIVATE_KEY :
26+ required : false
27+ SSH_KNOWN_HOSTS :
28+ required : false
1329
1430permissions :
1531 contents : read
@@ -18,9 +34,9 @@ permissions:
1834jobs :
1935 test :
2036 name : Pre-commit Tests
21- runs-on : ubuntu-latest
37+ runs-on : ${{ inputs.runs-on }}
2238 container :
23- image : ghcr.io/makeitworkcloud/runner:latest
39+ image : ${{ inputs.container }}
2440 env :
2541 SOPS_AGE_KEY : ${{ secrets.SOPS_AGE_KEY }}
2642 steps :
2945 with :
3046 fetch-depth : 0
3147
48+ - name : Install SSH key
49+ if : ${{ inputs.setup-ssh }}
50+ uses : shimataro/ssh-key-action@v2
51+ with :
52+ key : ${{ secrets.SSH_PRIVATE_KEY }}
53+ known_hosts : ${{ secrets.SSH_KNOWN_HOSTS }}
54+
55+ - name : Copy SSH area
56+ if : ${{ inputs.setup-ssh }}
57+ run : cp -r /root/.ssh /github/home/
58+
3259 - name : Initialize OpenTofu
3360 run : tofu init -backend=false
3461
3764
3865 plan :
3966 name : OpenTofu Plan
40- runs-on : ubuntu-latest
67+ runs-on : ${{ inputs.runs-on }}
4168 container :
42- image : ghcr.io/makeitworkcloud/runner:latest
69+ image : ${{ inputs.container }}
4370 if : github.event_name == 'pull_request'
4471 needs : [test]
4572 env :
4875 - name : Checkout
4976 uses : actions/checkout@v4
5077
78+ - name : Install SSH key
79+ if : ${{ inputs.setup-ssh }}
80+ uses : shimataro/ssh-key-action@v2
81+ with :
82+ key : ${{ secrets.SSH_PRIVATE_KEY }}
83+ known_hosts : ${{ secrets.SSH_KNOWN_HOSTS }}
84+
85+ - name : Copy SSH area
86+ if : ${{ inputs.setup-ssh }}
87+ run : cp -r /root/.ssh /github/home/
88+
5189 - name : OpenTofu Plan
5290 id : plan
5391 run : |
81119
82120 apply :
83121 name : OpenTofu Apply
84- runs-on : ubuntu-latest
122+ runs-on : ${{ inputs.runs-on }}
85123 container :
86- image : ghcr.io/makeitworkcloud/runner:latest
124+ image : ${{ inputs.container }}
87125 if : github.event_name == 'push' && github.ref == 'refs/heads/main'
88126 needs : [test]
89127 environment : ${{ inputs.environment }}
@@ -93,5 +131,16 @@ jobs:
93131 - name : Checkout
94132 uses : actions/checkout@v4
95133
134+ - name : Install SSH key
135+ if : ${{ inputs.setup-ssh }}
136+ uses : shimataro/ssh-key-action@v2
137+ with :
138+ key : ${{ secrets.SSH_PRIVATE_KEY }}
139+ known_hosts : ${{ secrets.SSH_KNOWN_HOSTS }}
140+
141+ - name : Copy SSH area
142+ if : ${{ inputs.setup-ssh }}
143+ run : cp -r /root/.ssh /github/home/
144+
96145 - name : OpenTofu Apply
97146 run : make apply
0 commit comments