|
| 1 | +name: Container Docker Image CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - '**.md' |
| 7 | + - 'charts/**' |
| 8 | + branches: |
| 9 | + - 'main' |
| 10 | + |
| 11 | +jobs: |
| 12 | + |
| 13 | + build: |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + packages: write |
| 18 | + id-token: write |
| 19 | + contents: read |
| 20 | + actions: read |
| 21 | + security-events: write |
| 22 | + env: |
| 23 | + REGISTRY: ghcr.io |
| 24 | + GH_URL: https://github.com |
| 25 | + steps: |
| 26 | + - name: Checkout GitHub Action |
| 27 | + uses: actions/checkout@v3 |
| 28 | + |
| 29 | + - name: Set up Docker Buildx |
| 30 | + id: buildx |
| 31 | + uses: docker/setup-buildx-action@v2 |
| 32 | + |
| 33 | + - name: Docker metadata |
| 34 | + id: metadata |
| 35 | + uses: docker/metadata-action@v4 |
| 36 | + with: |
| 37 | + images: ${{ env.REGISTRY }}/${{ github.repository }} |
| 38 | + tags: | |
| 39 | + type=semver,pattern={{version}} |
| 40 | + type=semver,pattern={{major}}.{{minor}} |
| 41 | + type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }} |
| 42 | + flavor: | |
| 43 | + latest=true |
| 44 | +
|
| 45 | + - name: Login to GitHub Container Registry |
| 46 | + uses: docker/login-action@v2 |
| 47 | + with: |
| 48 | + registry: ${{ env.REGISTRY }} |
| 49 | + username: ${{ github.actor }} |
| 50 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + |
| 52 | + - name: Build image and push to GitHub Container Registry |
| 53 | + uses: docker/build-push-action@v4 |
| 54 | + with: |
| 55 | + context: . |
| 56 | + file: ./Dockerfile |
| 57 | + tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.run_id }} |
| 58 | + labels: ${{ steps.metadata.outputs.labels }} |
| 59 | + |
| 60 | + push: true |
| 61 | + |
| 62 | + - name: Install cosign |
| 63 | + uses: sigstore/cosign-installer@main |
| 64 | + |
| 65 | + - name: Sign the images |
| 66 | + run: | |
| 67 | + cosign sign -y ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.run_id }} |
| 68 | + env: |
| 69 | + COSIGN_EXPERIMENTAL: 1 |
| 70 | + |
| 71 | + - name: Verify the pushed tags |
| 72 | + run: cosign verify ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.run_id }} --certificate-identity ${{ env.GH_URL }}/${{ github.repository }}/.github/workflows/container.yml@refs/heads/main --certificate-oidc-issuer https://token.actions.githubusercontent.com |
| 73 | + env: |
| 74 | + COSIGN_EXPERIMENTAL: 1 |
| 75 | + |
| 76 | + - name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph |
| 77 | + uses: aquasecurity/trivy-action@master |
| 78 | + with: |
| 79 | + scan-type: 'fs' |
| 80 | + format: 'github' |
| 81 | + output: 'dependency-results.sbom.json' |
| 82 | + image-ref: '.' |
| 83 | + github-pat: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments