-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (66 loc) · 2.16 KB
/
pr.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:
pull_request:
branches:
- main
jobs:
getDirs:
runs-on: ubuntu-latest
outputs:
dir: ${{ steps.set-dirs.outputs.dir }}
steps:
- uses: actions/checkout@v4
- id: set-dirs
run: echo "dir=$(ls -d *-cluster/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
plan:
runs-on: ubuntu-latest
needs: [getDirs]
strategy:
matrix:
cluster: ${{fromJson(needs.getDirs.outputs.dir)}}
defaults:
run:
working-directory: ${{ matrix.cluster }}
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
- uses: aquasecurity/[email protected]
id: tfsec
with:
additional_args: "--out tfsec.xml"
soft_fail: true
format: junit
- uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: 'tfsec.xml'
- name: Terraform Init
id: init
run: terraform init -upgrade
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Set Cluster ID
id: env_var
run: |
echo "CLUSTER_ID=$(cat CLUSTERID.md)" >> $GITHUB_OUTPUT
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Setup Kubeconfig
id: kubeconfig
run: |
curl -X GET "https://kaas.cloudpunks.io/api/v2/projects/${{ secrets.KAAS_PROJECT_ID }}/clusters/${{ steps.env_var.outputs.CLUSTER_ID }}/kubeconfig" \
-H "accept: application/octet-stream" -H "Authorization: Bearer ${{ secrets.SA_DEV_INTERN }}" > .kubeconfig
chmod go-r .kubeconfig
export KUBECONFIG=.kubeconfig
- name: Terraform Plan
id: plan
run: terraform plan -no-color
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}