|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - '[0-9]+.[0-9]+.x' |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + REGISTRY: quay.io |
| 12 | + GITHUB_PAGES_BRANCH: gh_pages |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + shell: bash |
| 17 | + |
| 18 | +jobs: |
| 19 | + release-please: |
| 20 | + permissions: |
| 21 | + contents: write # for google-github-actions/release-please-action to create release commit |
| 22 | + pull-requests: write # for google-github-actions/release-please-action to create release PR |
| 23 | + runs-on: [self-hosted, Linux, X64, validator] |
| 24 | + outputs: |
| 25 | + releases_created: ${{ steps.release.outputs.releases_created }} |
| 26 | + tag_name: ${{ steps.release.outputs.tag_name }} |
| 27 | + # Release-please creates a PR that tracks all changes |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 31 | + |
| 32 | + - uses: google-github-actions/release-please-action@a37ac6e4f6449ce8b3f7607e4d97d0146028dc0b # v4 |
| 33 | + id: release |
| 34 | + with: |
| 35 | + command: manifest |
| 36 | + token: ${{secrets.PAT}} |
| 37 | + default-branch: main |
| 38 | + |
| 39 | + release-charts: |
| 40 | + needs: release-please |
| 41 | + permissions: |
| 42 | + contents: write |
| 43 | + runs-on: [self-hosted, Linux, X64, validator] |
| 44 | + if: needs.release-please.outputs.releases_created == 'true' |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 47 | + - name: Publish Helm chart |
| 48 | + uses: stefanprodan/helm-gh-pages@master |
| 49 | + with: |
| 50 | + token: ${{ secrets.PAT }} |
| 51 | + charts_dir: chart |
| 52 | + owner: spectrocloud-labs |
| 53 | + branch: ${{ env.GITHUB_PAGES_BRANCH }} |
| 54 | + commit_username: spectrocloud-labs-bot |
| 55 | + |
| 56 | + |
| 57 | + build-container: |
| 58 | + if: needs.release-please.outputs.releases_created == 'true' |
| 59 | + needs: |
| 60 | + - release-please |
| 61 | + runs-on: [self-hosted, Linux, X64, validator] |
| 62 | + permissions: |
| 63 | + contents: write |
| 64 | + packages: write |
| 65 | + id-token: write |
| 66 | + env: |
| 67 | + IMAGE_TAG: quay.io/spectrocloud-labs/validator-plugin-kubescape:${{ needs.release-please.outputs.tag_name }} |
| 68 | + IMAGE_NAME: validator-plugin-kubescape |
| 69 | + steps: |
| 70 | + - name: Checkout |
| 71 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 72 | + with: |
| 73 | + submodules: recursive |
| 74 | + |
| 75 | + - name: Set up Docker Buildx |
| 76 | + id: buildx |
| 77 | + uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3 |
| 78 | + |
| 79 | + - name: Login to GitHub Container Registry |
| 80 | + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3 |
| 81 | + with: |
| 82 | + registry: "quay.io" |
| 83 | + username: tgillson |
| 84 | + password: ${{ secrets.QUAY_TOKEN }} |
| 85 | + |
| 86 | + - name: Build Docker Image |
| 87 | + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5 |
| 88 | + with: |
| 89 | + context: . |
| 90 | + file: ./Dockerfile |
| 91 | + platforms: linux/amd64,linux/arm64 |
| 92 | + target: production |
| 93 | + tags: | |
| 94 | + ${{ env.IMAGE_TAG }} |
| 95 | + builder: ${{ steps.buildx.outputs.name }} |
| 96 | + push: true |
| 97 | + cache-from: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_TAG }} |
| 98 | + cache-to: type=gha,scope=${{ github.ref_name }}-${{ env.IMAGE_TAG }} |
| 99 | + |
| 100 | + - name: Generate SBOM |
| 101 | + uses: anchore/sbom-action@9fece9e20048ca9590af301449208b2b8861333b # v0.15.9 |
| 102 | + with: |
| 103 | + image: ${{ env.IMAGE_TAG }} |
| 104 | + artifact-name: sbom-${{ env.IMAGE_NAME }} |
| 105 | + output-file: ./sbom-${{ env.IMAGE_NAME }}.spdx.json |
| 106 | + |
| 107 | + - name: Attach SBOM to release |
| 108 | + uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2 |
| 109 | + with: |
| 110 | + tag_name: ${{ needs.release-please.outputs.tag_name }} |
| 111 | + files: ./sbom-${{ env.IMAGE_NAME }}.spdx.json |
0 commit comments