|
1 | | -name: Terraform Apply |
| 1 | +name: Terraform |
| 2 | + |
2 | 3 | on: |
3 | 4 | pull_request: |
4 | 5 | workflow_dispatch: |
|
7 | 8 | - main |
8 | 9 |
|
9 | 10 | jobs: |
10 | | - run-mock-k8s-and-apply: |
| 11 | + terraform-plan: |
| 12 | + name: Terraform Plan |
11 | 13 | runs-on: ubuntu-latest |
12 | 14 | steps: |
13 | 15 | - uses: actions/checkout@v4 |
14 | 16 | with: |
15 | | - fetch-depth: 0 |
16 | | - - name: Install terraform |
17 | | - run: | |
18 | | - wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg |
19 | | - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list |
20 | | - sudo apt update && sudo apt install terraform -y |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Setup Terraform |
| 20 | + uses: hashicorp/setup-terraform@v3 |
| 21 | + with: |
| 22 | + terraform_version: "1.5.0" |
| 23 | + |
21 | 24 | - name: Configure mkcert |
22 | | - run: | |
| 25 | + run: | |
23 | 26 | sudo apt install ca-certificates libnss3-tools -y |
24 | | - wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64 |
| 27 | + wget -q https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64 |
25 | 28 | chmod +x ./mkcert-v1.4.4-linux-amd64 |
26 | 29 | sudo mv ./mkcert-v1.4.4-linux-amd64 /usr/local/bin/mkcert |
27 | 30 | mkcert --install |
28 | | - ls -la "$(mkcert -CAROOT)" |
29 | | - - name: Testing on a k8s Kind Cluster |
| 31 | +
|
| 32 | + - name: Create Kind cluster |
30 | 33 | uses: helm/kind-action@v1.12.0 |
31 | | - - run: | |
| 34 | + |
| 35 | + - name: Configure kubectl context |
| 36 | + run: | |
32 | 37 | kubectl cluster-info |
33 | 38 | kubectl get nodes |
34 | 39 | kubectl config rename-context kind-chart-testing docker-desktop |
35 | | - - name : Preparing cluster for kube-ez |
| 40 | +
|
| 41 | + - name: Terraform Init |
| 42 | + run: | |
| 43 | + export TF_VAR_cluster_issuer_selfsigned_ca_cert="$(base64 < "$(mkcert -CAROOT)/rootCA.pem")" |
| 44 | + export TF_VAR_cluster_issuer_selfsigned_ca_key="$(base64 < "$(mkcert -CAROOT)/rootCA-key.pem")" |
| 45 | + make tf-init |
| 46 | +
|
| 47 | + - name: Terraform Plan |
| 48 | + run: | |
| 49 | + export TF_VAR_cluster_issuer_selfsigned_ca_cert="$(base64 < "$(mkcert -CAROOT)/rootCA.pem")" |
| 50 | + export TF_VAR_cluster_issuer_selfsigned_ca_key="$(base64 < "$(mkcert -CAROOT)/rootCA-key.pem")" |
| 51 | + make tf-plan |
| 52 | +
|
| 53 | + terraform-apply: |
| 54 | + name: Terraform Apply |
| 55 | + needs: terraform-plan |
| 56 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 57 | + runs-on: ubuntu-latest |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + with: |
| 61 | + fetch-depth: 0 |
| 62 | + |
| 63 | + - name: Setup Terraform |
| 64 | + uses: hashicorp/setup-terraform@v3 |
| 65 | + with: |
| 66 | + terraform_version: "1.5.0" |
| 67 | + |
| 68 | + - name: Configure mkcert |
| 69 | + run: | |
| 70 | + sudo apt install ca-certificates libnss3-tools -y |
| 71 | + wget -q https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64 |
| 72 | + chmod +x ./mkcert-v1.4.4-linux-amd64 |
| 73 | + sudo mv ./mkcert-v1.4.4-linux-amd64 /usr/local/bin/mkcert |
| 74 | + mkcert --install |
| 75 | +
|
| 76 | + - name: Create Kind cluster |
| 77 | + uses: helm/kind-action@v1.12.0 |
| 78 | + |
| 79 | + - name: Configure kubectl context |
| 80 | + run: | |
| 81 | + kubectl cluster-info |
| 82 | + kubectl get nodes |
| 83 | + kubectl config rename-context kind-chart-testing docker-desktop |
| 84 | +
|
| 85 | + - name: Terraform Apply |
36 | 86 | run: | |
37 | 87 | export TF_VAR_cluster_issuer_selfsigned_ca_cert="$(base64 < "$(mkcert -CAROOT)/rootCA.pem")" |
38 | 88 | export TF_VAR_cluster_issuer_selfsigned_ca_key="$(base64 < "$(mkcert -CAROOT)/rootCA-key.pem")" |
|
0 commit comments