|
| 1 | +name: Terraform |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + |
| 7 | + # -- TESTS ------------------------------------------------------------------ |
| 8 | + tests: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + env: |
| 12 | + TF_VAR_tenancy_ocid: ${{secrets.OCI_TENANCY_OCID}} |
| 13 | + TF_VAR_user_ocid: ${{secrets.OCI_USER_OCID}} |
| 14 | + TF_VAR_fingerprint: ${{secrets.OCI_FINGERPRINT}} |
| 15 | + TF_VAR_private_key: ${{secrets.OCI_PRIVATE_KEY}} |
| 16 | + TF_VAR_region: ${{secrets.OCI_REGION}} |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 |
| 21 | + |
| 22 | + - name: Setup Terraform |
| 23 | + uses: hashicorp/setup-terraform@17d4c9b8043b238f6f35641cdd8433da1e6f3867 # tag=v2.0.0 |
| 24 | + |
| 25 | + - name: Terraform Format |
| 26 | + id: fmt |
| 27 | + run: terraform fmt -check |
| 28 | + continue-on-error: true |
| 29 | + |
| 30 | + - name: Terraform Init |
| 31 | + id: init |
| 32 | + run: terraform init |
| 33 | + |
| 34 | + - name: Terraform Plan |
| 35 | + id: apply |
| 36 | + run: terraform plan |
| 37 | + |
| 38 | + # -- SAST SCAN -------------------------------------------------------------- |
| 39 | + code-security: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + needs: tests |
| 42 | + # Skip any PR created by dependabot to avoid permission issues |
| 43 | + if: (github.actor != 'dependabot[bot]') |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 |
| 48 | + |
| 49 | + - name: Perform Scan |
| 50 | + uses: ShiftLeftSecurity/scan-action@master |
| 51 | + |
| 52 | + env: |
| 53 | + WORKSPACE: https://github.com/${{ github.repository }}/blob/${{ github.sha }} |
| 54 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + SCAN_ANNOTATE_PR: true |
| 56 | + |
| 57 | + - uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # tag=v3.0.0 |
| 58 | + with: |
| 59 | + name: reports |
| 60 | + path: reports |
| 61 | + |
| 62 | + # -- DOCUMENTATION ---------------------------------------------------------- |
| 63 | + documentation: |
| 64 | + runs-on: ubuntu-latest |
| 65 | + needs: tests |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Checkout |
| 69 | + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 |
| 70 | + |
| 71 | + - name: Terraform Docs |
| 72 | + uses: terraform-docs/gh-actions@f6d59f89a280fa0a3febf55ef68f146784b20ba0 # tag=v1.0.0 |
| 73 | + with: |
| 74 | + working-dir: . |
| 75 | + output-file: USAGE.md |
| 76 | + output-method: inject |
| 77 | + git-push: "true" |
| 78 | + git-commit-message: "chore(docs): update Terraform docs" |
| 79 | + |
| 80 | + # -- RELEASE ---------------------------------------------------------------- |
| 81 | + release: |
| 82 | + runs-on: ubuntu-latest |
| 83 | + needs: |
| 84 | + - tests |
| 85 | + - code-security |
| 86 | + - documentation |
| 87 | + if: github.ref == 'refs/heads/main' |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Checkout |
| 91 | + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 |
| 92 | + with: |
| 93 | + ref: 'main' # Force checkout of main branch to avoid caching from previous jobs |
| 94 | + persist-credentials: false |
| 95 | + |
| 96 | + - name: Semantic Release |
| 97 | + uses: cycjimmy/semantic-release-action@v3 |
| 98 | + env: |
| 99 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments