|
7 | 7 | tags: ["v*"]
|
8 | 8 | branches: [ main ]
|
9 | 9 | workflow_dispatch:
|
| 10 | + # Run on pull requests to test docker build. |
| 11 | + # We explicitly do not push on pull requests (the job below is ended early). |
| 12 | + # |
| 13 | + # note: secrets will not be populated on pull requests from external authors. |
| 14 | + pull_request: |
10 | 15 |
|
11 | 16 | permissions:
|
12 | 17 | contents: read
|
|
19 | 24 | - name: Set up Docker Buildx
|
20 | 25 | uses: docker/setup-buildx-action@v2
|
21 | 26 |
|
22 |
| - - name: Log in to DockerHub |
23 |
| - uses: docker/login-action@v2 |
24 |
| - with: |
25 |
| - username: ${{ secrets.DOCKER_HUB_USERNAME }} |
26 |
| - password: ${{ secrets.DOCKER_HUB_TOKEN }} |
27 |
| - |
28 |
| - - name: Log in to GHCR |
29 |
| - uses: docker/login-action@v2 |
30 |
| - with: |
31 |
| - registry: ghcr.io |
32 |
| - username: ${{ github.repository_owner }} |
33 |
| - password: ${{ secrets.GITHUB_TOKEN }} |
34 |
| - |
35 | 27 | - name: Calculate docker image tag
|
36 | 28 | id: set-tag
|
37 | 29 | uses: docker/metadata-action@master
|
|
46 | 38 | type=sha,prefix=,format=long
|
47 | 39 | type=semver,pattern=v{{version}}
|
48 | 40 | type=semver,pattern=v{{major}}.{{minor}}
|
| 41 | + |
| 42 | + - name: Don't push to registry if this is a PR |
| 43 | + if: "${{ github.event_name }}" = "pull_request" |
| 44 | + run: | |
| 45 | + echo "Not pushing the image to any container registry as this workflow is running on a pull request" |
| 46 | + exit 0 |
| 47 | +
|
| 48 | + - name: Log in to DockerHub |
| 49 | + uses: docker/login-action@v2 |
| 50 | + with: |
| 51 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 52 | + password: ${{ secrets.DOCKER_HUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Log in to GHCR |
| 55 | + uses: docker/login-action@v2 |
| 56 | + with: |
| 57 | + registry: ghcr.io |
| 58 | + username: ${{ github.repository_owner }} |
| 59 | + password: ${{ secrets.GITHUB_TOKEN }} |
49 | 60 |
|
50 | 61 | - name: Build and push all platforms
|
51 | 62 | uses: docker/build-push-action@v4
|
|
0 commit comments