|
1 | 1 | name: Publish Docker image |
2 | | - |
3 | | -"on": |
| 2 | +on: |
4 | 3 | release: |
5 | 4 | types: [published] |
6 | | - workflow_dispatch: |
7 | | - inputs: |
8 | | - tag: |
9 | | - description: "Tag to build and push" |
10 | | - required: true |
11 | | - default: "latest" |
12 | | - |
13 | | -env: |
14 | | - REGISTRY_GITHUB: ghcr.io |
15 | | - REGISTRY_DOCKERHUB: docker.io |
16 | | - IMAGE_NAME: netflix/dispatch |
17 | | - |
18 | 5 | jobs: |
19 | 6 | push_to_registry: |
20 | | - name: Build and push Docker image |
| 7 | + name: Push Docker image to GitHub Packages |
21 | 8 | runs-on: ubuntu-latest |
22 | | - permissions: |
23 | | - contents: read |
24 | | - packages: write |
25 | | - security-events: write |
26 | 9 | steps: |
27 | 10 | - name: Check out the repo |
28 | 11 | uses: actions/checkout@v4 |
29 | | - |
30 | | - - name: Set up QEMU |
31 | | - uses: docker/setup-qemu-action@v3 |
32 | | - |
33 | | - - name: Set up Docker Buildx |
34 | | - uses: docker/setup-buildx-action@v3 |
35 | | - |
36 | | - - name: Log in to GitHub Container Registry |
37 | | - uses: docker/login-action@v3 |
| 12 | + - name: Push to GitHub Packages |
| 13 | + uses: docker/build-push-action@v1 |
38 | 14 | with: |
39 | | - registry: ${{ env.REGISTRY_GITHUB }} |
40 | 15 | username: ${{ github.actor }} |
41 | 16 | password: ${{ secrets.GITHUB_TOKEN }} |
42 | | - |
43 | | - - name: Log in to Docker Hub |
44 | | - uses: docker/login-action@v3 |
45 | | - continue-on-error: true |
46 | | - with: |
47 | | - registry: ${{ env.REGISTRY_DOCKERHUB }} |
48 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
49 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
50 | | - |
51 | | - - name: Extract metadata |
52 | | - id: meta |
53 | | - uses: docker/metadata-action@v5 |
54 | | - with: |
55 | | - images: | |
56 | | - ${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }} |
57 | | - ${{ env.REGISTRY_DOCKERHUB }}/${{ env.IMAGE_NAME }} |
58 | | - tags: | |
59 | | - type=ref,event=tag |
60 | | - type=ref,event=branch |
61 | | - type=semver,pattern={{version}} |
62 | | - type=semver,pattern={{major}}.{{minor}} |
63 | | - type=semver,pattern={{major}} |
64 | | - type=raw,value=latest,enable={{is_default_branch}} |
65 | | -
|
66 | | - - name: Build and push Docker image |
67 | | - uses: docker/build-push-action@v6 |
68 | | - with: |
69 | | - context: . |
70 | | - file: ./Dockerfile |
71 | | - platforms: linux/amd64,linux/arm64 |
72 | | - push: true |
73 | | - tags: ${{ steps.meta.outputs.tags }} |
74 | | - labels: ${{ steps.meta.outputs.labels }} |
75 | | - cache-from: type=gha |
76 | | - cache-to: type=gha,mode=max |
77 | | - build-args: | |
78 | | - SOURCE_COMMIT=${{ github.sha }} |
79 | | - VITE_DISPATCH_COMMIT_HASH=${{ github.sha }} |
80 | | -
|
81 | | - # - name: Run Trivy vulnerability scanner |
82 | | - # uses: aquasecurity/trivy-action@master |
83 | | - # with: |
84 | | - # image-ref: ${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} |
85 | | - # format: "sarif" |
86 | | - # output: "trivy-results.sarif" |
87 | | - |
88 | | - # - name: Upload Trivy scan results to GitHub Security tab |
89 | | - # uses: github/codeql-action/upload-sarif@v3 |
90 | | - # if: always() |
91 | | - # with: |
92 | | - # sarif_file: "trivy-results.sarif" |
93 | | - |
94 | | - # - name: Generate SBOM |
95 | | - # uses: anchore/sbom-action@v0 |
96 | | - # with: |
97 | | - # image: ${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} |
98 | | - # format: spdx-json |
99 | | - # output-file: sbom.spdx.json |
100 | | - |
101 | | - # - name: Upload SBOM |
102 | | - # uses: actions/upload-artifact@v4 |
103 | | - # with: |
104 | | - # name: sbom |
105 | | - # path: sbom.spdx.json |
| 17 | + registry: docker.pkg.github.com |
| 18 | + repository: netflix/dispatch/dispatch-image |
| 19 | + tag_with_ref: true |
0 commit comments