|
8 | 8 |
|
9 | 9 | jobs:
|
10 | 10 |
|
11 |
| - terraform_nap: |
12 |
| - name: "NGINX App Protect" |
13 |
| - runs-on: ubuntu-latest |
14 |
| - defaults: |
15 |
| - run: |
16 |
| - working-directory: ./nap |
17 |
| - steps: |
18 |
| - - name: Checkout |
19 |
| - uses: actions/checkout@v3 |
20 |
| - |
21 |
| - - name: Setup Terraform |
22 |
| - uses: hashicorp/setup-terraform@v2 |
23 |
| - with: |
24 |
| - cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} |
25 |
| - |
26 |
| - - name: Setup Terraform Backend |
27 |
| - id: backend |
28 |
| - run: | |
29 |
| - cat > backend.tf << EOF |
30 |
| - terraform { |
31 |
| - cloud { |
32 |
| - organization = "${{ secrets.TF_CLOUD_ORGANIZATION }}" |
33 |
| - workspaces { |
34 |
| - name = "${{ secrets.TF_CLOUD_WORKSPACE_NAP }}" |
35 |
| - } |
36 |
| - } |
37 |
| - } |
38 |
| - EOF |
39 |
| - echo ${{secrets.NGINX_JWT}} | base64 -d > nginx-repo.jwt |
40 |
| - - name: Terraform Init |
41 |
| - id: init |
42 |
| - run: terraform init |
43 |
| - |
44 |
| - - name: Terraform Validate |
45 |
| - id: validate |
46 |
| - run: terraform validate -no-color |
47 |
| - |
48 |
| - - name: Terraform Plan |
49 |
| - id: plan |
50 |
| - if: github.event_name == 'pull_request' |
51 |
| - run: terraform plan -no-color -input=false |
52 |
| - continue-on-error: true |
53 |
| - |
54 |
| - - uses: actions/github-script@v6 |
55 |
| - if: github.event_name == 'pull_request' |
56 |
| - env: |
57 |
| - PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" |
58 |
| - with: |
59 |
| - github-token: ${{ secrets.GITHUB_TOKEN }} |
60 |
| - script: | |
61 |
| - const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` |
62 |
| - #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` |
63 |
| - #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` |
64 |
| - #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` |
65 |
| - <details><summary>Show Plan</summary> |
66 |
| - \`\`\`\n |
67 |
| - ${process.env.PLAN} |
68 |
| - \`\`\` |
69 |
| - </details> |
70 |
| - *Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; |
71 |
| - github.rest.issues.createComment({ |
72 |
| - issue_number: context.issue.number, |
73 |
| - owner: context.repo.owner, |
74 |
| - repo: context.repo.repo, |
75 |
| - body: output |
76 |
| - }) |
77 |
| - - name: Terraform Plan Status |
78 |
| - if: steps.plan.outcome == 'failure' |
79 |
| - run: exit 1 |
80 |
| - |
81 |
| - - name: Terraform Destroy |
82 |
| - if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
83 |
| - run: terraform destroy -auto-approve -input=false |
84 |
| - |
85 | 11 | terraform_eks:
|
86 | 12 | name: "AWS EKS"
|
87 | 13 | runs-on: ubuntu-latest
|
88 |
| - needs: terraform_nap |
89 | 14 | defaults:
|
90 | 15 | run:
|
91 | 16 | working-directory: ./eks-cluster
|
|
0 commit comments