|
| 1 | +name: Test & Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + branches: ["main"] |
| 8 | + |
| 9 | +permissions: |
| 10 | + actions: read |
| 11 | + contents: write |
| 12 | + statuses: read |
| 13 | + |
| 14 | +env: |
| 15 | + TF_VAR_github_app_id: ${{ secrets.GH_APP_ID }} |
| 16 | + TF_VAR_github_app_install_id: ${{ secrets.GH_APP_INSTALL_ID }} |
| 17 | + TF_VAR_github_app_private_key: ${{ secrets.GH_APP_KEY }} |
| 18 | + TF_VAR_labels: '["test", "${{ github.run_id }}"]' |
| 19 | + |
| 20 | +jobs: |
| 21 | + lint: |
| 22 | + name: Lint |
| 23 | + runs-on: ubuntu-latest |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + directory: |
| 27 | + - "." |
| 28 | + - "examples/full" |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + - name: Lint Example |
| 33 | + uses: "infinite-automations/[email protected]" |
| 34 | + with: |
| 35 | + directory: ${{ matrix.directory }} |
| 36 | + |
| 37 | + update-docs: |
| 38 | + name: Update Docs |
| 39 | + needs: |
| 40 | + - lint |
| 41 | + runs-on: ubuntu-latest |
| 42 | + concurrency: |
| 43 | + group: ${{ github.ref }}-docs |
| 44 | + cancel-in-progress: false |
| 45 | + outputs: |
| 46 | + changed: ${{ steps.terraform-docs.outputs.num_changed > 0 }} |
| 47 | + steps: |
| 48 | + - name: Checkout |
| 49 | + uses: actions/checkout@v4 |
| 50 | + if: ${{ github.event_name == 'push' }} |
| 51 | + - name: Checkout |
| 52 | + uses: actions/checkout@v4 |
| 53 | + if: ${{ github.event_name == 'pull_request' }} |
| 54 | + with: |
| 55 | + ref: ${{ github.event.pull_request.head.ref }} |
| 56 | + - name: Render terraform docs inside the README.md |
| 57 | + id: terraform-docs |
| 58 | + uses: terraform-docs/[email protected] |
| 59 | + with: |
| 60 | + working-dir: .,examples/full |
| 61 | + output-file: README.md |
| 62 | + output-method: inject |
| 63 | + git-push: ${{ github.event_name == 'pull_request' }} |
| 64 | + git-commit-message: "docs(terraform): update README.md" |
| 65 | + - name: Cache Docs |
| 66 | + if: ${{ github.event_name == 'push' }} |
| 67 | + uses: actions/cache@v3 |
| 68 | + with: |
| 69 | + path: | |
| 70 | + README.md |
| 71 | + examples/full/README.md |
| 72 | + key: ${{ runner.os }}-docs-${{ github.sha }} |
| 73 | + |
| 74 | + setup-runner: |
| 75 | + name: Setup Runner |
| 76 | + needs: |
| 77 | + - lint |
| 78 | + - update-docs |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - name: Checkout |
| 82 | + uses: actions/checkout@v4 |
| 83 | + - name: Create k8s Kind Cluster |
| 84 | + |
| 85 | + with: |
| 86 | + wait: "120s" |
| 87 | + - name: Create Runners |
| 88 | + uses: infinite-automations/[email protected] |
| 89 | + id: apply-example |
| 90 | + with: |
| 91 | + directory: "examples/full" |
| 92 | + plan: false |
| 93 | + apply: true |
| 94 | + destroy: false |
| 95 | + - name: Wait For Test |
| 96 | + uses: yogeshlonkar/wait-for-jobs@v0 |
| 97 | + with: |
| 98 | + gh-token: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + jobs: "Test" |
| 100 | + prefix: true |
| 101 | + ttl: "10" |
| 102 | + - name: Destroy Runners |
| 103 | + uses: infinite-automations/[email protected] |
| 104 | + if: always() |
| 105 | + with: |
| 106 | + directory: "examples/full" |
| 107 | + plan: false |
| 108 | + apply: false |
| 109 | + destroy: true |
| 110 | + destroy-args: '-target="kubectl_manifest.runner"' |
| 111 | + |
| 112 | + test-runner: |
| 113 | + name: Test |
| 114 | + needs: |
| 115 | + - lint |
| 116 | + - update-docs |
| 117 | + runs-on: |
| 118 | + - self-hosted |
| 119 | + - test |
| 120 | + - ${{ github.run_id }} |
| 121 | + strategy: |
| 122 | + matrix: |
| 123 | + image: |
| 124 | + - alpine:latest |
| 125 | + - ubuntu:latest |
| 126 | + - debian:latest |
| 127 | + container: |
| 128 | + image: ${{ matrix.image }} |
| 129 | + timeout-minutes: 10 |
| 130 | + steps: |
| 131 | + - name: Print Environment Information |
| 132 | + run: | |
| 133 | + echo "Operating System: $OSTYPE" |
| 134 | + echo "Hostname: $(hostname)" |
| 135 | + echo "CPU Architecture: $(uname -m)" |
| 136 | + echo "Kernel Version: $(uname -r)" |
| 137 | + echo |
| 138 | + cat /etc/os-release |
| 139 | +
|
| 140 | + release: |
| 141 | + name: Release |
| 142 | + needs: |
| 143 | + - update-docs |
| 144 | + - setup-runner |
| 145 | + - test-runner |
| 146 | + concurrency: |
| 147 | + group: ${{ github.ref }}-release |
| 148 | + cancel-in-progress: false |
| 149 | + runs-on: ubuntu-latest |
| 150 | + steps: |
| 151 | + - name: Checkout |
| 152 | + uses: actions/checkout@v4 |
| 153 | + - name: Restore Cached Docs |
| 154 | + if: ${{ github.event_name == 'push' }} |
| 155 | + uses: actions/cache@v3 |
| 156 | + with: |
| 157 | + path: README.md |
| 158 | + key: ${{ runner.os }}-docs-${{ github.sha }} |
| 159 | + - name: Semantic Release |
| 160 | + uses: cycjimmy/semantic-release-action@v4 |
| 161 | + with: |
| 162 | + dry_run: ${{ github.event_name == 'pull_request' }} |
| 163 | + ci: true |
| 164 | + env: |
| 165 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments