|
| 1 | +name: Docker |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + merge_group: |
| 7 | + schedule: |
| 8 | + - cron: "0 0 * * *" |
| 9 | + push: |
| 10 | + branches: [ "main" ] |
| 11 | + release: |
| 12 | + types: [ published ] |
| 13 | + |
| 14 | +permissions: read-all |
| 15 | + |
| 16 | +jobs: |
| 17 | + lint: |
| 18 | + name: Lint Dockerfile |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 22 | + - uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0 |
| 23 | + |
| 24 | + build: |
| 25 | + name: Build and publish |
| 26 | + runs-on: ubuntu-24.04-arm |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + packages: write |
| 30 | + attestations: write |
| 31 | + id-token: write |
| 32 | + security-events: write |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 35 | + - uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 |
| 36 | + with: |
| 37 | + registry: ghcr.io |
| 38 | + username: ${{ github.actor }} |
| 39 | + password: ${{ github.token }} |
| 40 | + - uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 |
| 41 | + - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
| 42 | + - uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 |
| 43 | + id: meta |
| 44 | + env: |
| 45 | + DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index |
| 46 | + with: |
| 47 | + images: ghcr.io/${{ github.repository }} |
| 48 | + tags: | |
| 49 | + type=schedule |
| 50 | + type=semver,pattern={{raw}} |
| 51 | + type=semver,pattern=v{{major}}.{{minor}} |
| 52 | + type=semver,pattern=v{{major}} |
| 53 | + type=ref,event=branch |
| 54 | + type=ref,event=pr |
| 55 | + # on.schedule: nightly |
| 56 | + # on.push:tag: latest (auto), v1.2.3, v.1,2, v.1 |
| 57 | + # on.push.branch: branchName |
| 58 | + # on.pull_request: pr-number (won't be pushed) |
| 59 | + |
| 60 | + - uses: docker/bake-action@3acf805d94d93a86cce4ca44798a76464a75b88c # v6.9.0 |
| 61 | + with: |
| 62 | + push: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' }} |
| 63 | + files: | |
| 64 | + cwd://${{ steps.meta.outputs.bake-file }} |
| 65 | + cwd://${{ steps.meta.outputs.bake-file-annotations }} |
| 66 | + ./docker-bake.hcl |
| 67 | + sbom: true |
| 68 | + provenance: true |
| 69 | + set: | |
| 70 | + *.cache-from=type=gha |
| 71 | + *.cache-to=type=gha,mode=max |
| 72 | +
|
| 73 | + - uses: anchore/scan-action@568b89d27fc18c60e56937bff480c91c772cd993 # v7.1.0 |
| 74 | + id: scan |
| 75 | + if: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' }} |
| 76 | + with: |
| 77 | + image: "ghcr.io/bsstudio/bss-web-file-api:${{ env.DOCKER_METADATA_OUTPUT_VERSION }}" |
| 78 | + cache-db: true |
| 79 | + severity-cutoff: 'high' |
| 80 | + fail-build: false |
| 81 | + |
| 82 | + - uses: github/codeql-action/upload-sarif@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0 |
| 83 | + if: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' }} |
| 84 | + with: |
| 85 | + sarif_file: ${{ steps.scan.outputs.sarif }} |
0 commit comments