|
1 | 1 | name: "F5XC + NAP Destroy"
|
| 2 | + |
2 | 3 | on:
|
3 | 4 | push:
|
4 | 5 | branches:
|
|
7 | 8 |
|
8 | 9 | jobs:
|
9 | 10 |
|
| 11 | + terraform_xc: |
| 12 | + name: "F5XC WAAP" |
| 13 | + runs-on: ubuntu-latest |
| 14 | + defaults: |
| 15 | + run: |
| 16 | + working-directory: ./xc |
| 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 | + - name: Setup Terraform Backend |
| 26 | + id: backend |
| 27 | + run: | |
| 28 | + cat > backend.tf << EOF |
| 29 | + terraform { |
| 30 | + cloud { |
| 31 | + organization = "${{ secrets.TF_CLOUD_ORGANIZATION }}" |
| 32 | + workspaces { |
| 33 | + name = "${{ secrets.TF_CLOUD_WORKSPACE_XC }}" |
| 34 | + } |
| 35 | + } |
| 36 | + } |
| 37 | + EOF |
| 38 | + echo "${{secrets.P12}}" | base64 -d > api.p12 |
| 39 | + - name: Terraform Init |
| 40 | + id: init |
| 41 | + run: terraform init |
| 42 | + |
| 43 | + - name: Terraform Validate |
| 44 | + id: validate |
| 45 | + run: terraform validate -no-color |
| 46 | + |
| 47 | + - name: Terraform Plan |
| 48 | + id: plan |
| 49 | + if: github.event_name == 'pull_request' |
| 50 | + run: terraform plan -no-color -input=false |
| 51 | + continue-on-error: true |
| 52 | + |
| 53 | + - uses: actions/github-script@v6 |
| 54 | + if: github.event_name == 'pull_request' |
| 55 | + env: |
| 56 | + PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" |
| 57 | + with: |
| 58 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + script: | |
| 60 | + const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` |
| 61 | + #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` |
| 62 | + #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` |
| 63 | + #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` |
| 64 | + <details><summary>Show Plan</summary> |
| 65 | + \`\`\`\n |
| 66 | + ${process.env.PLAN} |
| 67 | + \`\`\` |
| 68 | + </details> |
| 69 | + *Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; |
| 70 | + github.rest.issues.createComment({ |
| 71 | + issue_number: context.issue.number, |
| 72 | + owner: context.repo.owner, |
| 73 | + repo: context.repo.repo, |
| 74 | + body: output |
| 75 | + }) |
| 76 | + - name: Terraform Plan Status |
| 77 | + if: steps.plan.outcome == 'failure' |
| 78 | + run: exit 1 |
| 79 | + |
| 80 | + - name: Terraform Destroy |
| 81 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 82 | + run: terraform destroy -auto-approve -input=false |
| 83 | + |
| 84 | + terraform_arcadia: |
| 85 | + name: "Arcadia WebApp" |
| 86 | + runs-on: ubuntu-latest |
| 87 | + needs: terraform_xc |
| 88 | + defaults: |
| 89 | + run: |
| 90 | + working-directory: ./arcadia |
| 91 | + steps: |
| 92 | + - name: Checkout |
| 93 | + uses: actions/checkout@v3 |
| 94 | + |
| 95 | + - name: Setup Terraform |
| 96 | + uses: hashicorp/setup-terraform@v2 |
| 97 | + with: |
| 98 | + cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} |
| 99 | + |
| 100 | + - name: Setup Terraform Backend |
| 101 | + id: backend |
| 102 | + run: | |
| 103 | + cat > backend.tf << EOF |
| 104 | + terraform { |
| 105 | + cloud { |
| 106 | + organization = "${{ secrets.TF_CLOUD_ORGANIZATION }}" |
| 107 | + workspaces { |
| 108 | + name = "${{ secrets.TF_CLOUD_WORKSPACE_ARCADIA }}" |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | + EOF |
| 113 | + - name: Terraform Init |
| 114 | + id: init |
| 115 | + run: terraform init |
| 116 | + |
| 117 | + - name: Terraform Validate |
| 118 | + id: validate |
| 119 | + run: terraform validate -no-color |
| 120 | + |
| 121 | + - name: Terraform Plan |
| 122 | + id: plan |
| 123 | + if: github.event_name == 'pull_request' |
| 124 | + run: terraform plan -no-color -input=false |
| 125 | + continue-on-error: true |
| 126 | + |
| 127 | + - uses: actions/github-script@v6 |
| 128 | + if: github.event_name == 'pull_request' |
| 129 | + env: |
| 130 | + PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" |
| 131 | + with: |
| 132 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + script: | |
| 134 | + const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` |
| 135 | + #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` |
| 136 | + #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` |
| 137 | + #### Terraform Plan 📖\`${{ steps.plan.outcome }}\` |
| 138 | + <details><summary>Show Plan</summary> |
| 139 | + \`\`\`\n |
| 140 | + ${process.env.PLAN} |
| 141 | + \`\`\` |
| 142 | + </details> |
| 143 | + *Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; |
| 144 | + github.rest.issues.createComment({ |
| 145 | + issue_number: context.issue.number, |
| 146 | + owner: context.repo.owner, |
| 147 | + repo: context.repo.repo, |
| 148 | + body: output |
| 149 | + }) |
| 150 | + - name: Terraform Plan Status |
| 151 | + if: steps.plan.outcome == 'failure' |
| 152 | + run: exit 1 |
| 153 | + |
| 154 | + - name: Terraform Destroy |
| 155 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 156 | + run: terraform destroy -auto-approve -input=false |
| 157 | + |
10 | 158 | terraform_nap:
|
11 | 159 | name: "NGINX App Protect"
|
12 | 160 | runs-on: ubuntu-latest
|
|
0 commit comments