Merge pull request #77 from deployah-dev/pin-workflow-action-versions #107
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ["v*"] | |
| permissions: | |
| contents: read | |
| jobs: | |
| osv-container-scan: | |
| name: OSV Container Scan | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| security-events: write | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 | |
| with: | |
| buildkitd-config-inline: | | |
| [worker.oci] | |
| max-parallelism = 10 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set version | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" | |
| else | |
| echo "VERSION=dev" >> "$GITHUB_ENV" | |
| fi | |
| - name: Build linux/amd64 image for scan | |
| uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0 | |
| with: | |
| targets: image | |
| load: true | |
| provenance: false | |
| vars: | | |
| VERSION=${{ env.VERSION }} | |
| set: | | |
| image.platform=linux/amd64 | |
| image.tags=deployah/deployah:osv-scan | |
| image.cache-from=type=gha,scope=image | |
| image.cache-to=type=gha,mode=max,scope=image | |
| - name: Save image archive | |
| run: docker save deployah/deployah:osv-scan -o deployah-amd64.tar | |
| - name: Run OSV-Scanner | |
| uses: google/osv-scanner-action/osv-scanner-action@9a498708959aeaef5ef730655706c5a1df1edbc2 # v2.3.8 | |
| continue-on-error: true | |
| with: | |
| scan-args: |- | |
| scan | |
| image | |
| --config=./osv-scanner.toml | |
| --output=results.json | |
| --format=json | |
| --archive | |
| ./deployah-amd64.tar | |
| - name: Report OSV-Scanner results | |
| uses: google/osv-scanner-action/osv-reporter-action@9a498708959aeaef5ef730655706c5a1df1edbc2 # v2.3.8 | |
| with: | |
| scan-args: |- | |
| --output=results.sarif | |
| --new=results.json | |
| --gh-annotations=false | |
| --fail-on-vuln=true | |
| - name: Upload SARIF | |
| if: ${{ !cancelled() }} | |
| uses: github/codeql-action/upload-sarif@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6 | |
| with: | |
| sarif_file: results.sarif | |
| category: osv-scanner-container | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: [osv-container-scan] | |
| permissions: | |
| contents: write | |
| discussions: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 | |
| with: | |
| images: deployah/deployah | |
| # 'latest' only on stable tags (no pre-release suffix like -alpha, -beta, -rc) | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=raw,value=latest,enable=${{ github.ref_type == 'tag' && !contains(github.ref_name, '-') }} | |
| type=edge,branch=${{ github.event.repository.default_branch }} | |
| flavor: | | |
| latest=false | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 | |
| with: | |
| buildkitd-config-inline: | | |
| [worker.oci] | |
| max-parallelism = 10 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set version | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" | |
| - name: Build artifacts | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0 | |
| with: | |
| targets: artifact | |
| provenance: false | |
| set: | | |
| artifact.cache-from=type=gha,scope=artifact | |
| artifact.cache-to=type=gha,mode=max,scope=artifact | |
| - name: Move artifacts | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| find ./dist -type f -not -name "SHA256SUMS" -exec mv {} ./dist/ \; | |
| find ./dist -name "SHA256SUMS" -exec cat {} \; | sort -u > ./dist/SHA256SUMS.combined | |
| mv ./dist/SHA256SUMS.combined ./dist/SHA256SUMS | |
| find ./dist -type d -empty -delete | |
| - name: Upload artifacts | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: deployah-artifacts | |
| path: ./dist/* | |
| if-no-files-found: error | |
| - name: Install Cosign | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 | |
| - name: Sign release artifacts | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| COSIGN_YES: "true" | |
| run: | | |
| set -euo pipefail | |
| shopt -s nullglob | |
| for f in dist/*.tar.gz dist/SHA256SUMS; do | |
| cosign sign-blob --yes --bundle "${f}.sigstore.json" "$f" | |
| done | |
| - name: Build and push image | |
| uses: docker/bake-action@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0 | |
| with: | |
| targets: image | |
| push: true | |
| sbom: true | |
| provenance: true | |
| files: | | |
| ./docker-bake.hcl | |
| cwd://${{ steps.meta.outputs.bake-file }} | |
| set: | | |
| image.cache-from=type=gha,scope=image | |
| image.cache-to=type=gha,mode=max,scope=image | |
| - name: Sync Docker Hub description | |
| uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0 | |
| if: github.ref_name == github.event.repository.default_branch | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| repository: deployah/deployah | |
| short-description: ${{ github.event.repository.description }} | |
| - name: GitHub Release | |
| uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| draft: true | |
| generate_release_notes: true | |
| discussion_category_name: Announcements | |
| # TODO: add dist/*.zip once windows targets are enabled. | |
| files: | | |
| dist/*.tar.gz | |
| dist/SHA256SUMS | |
| dist/*.sigstore.json | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |