|
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support |
| 4 | +# documentation. |
| 5 | + |
| 6 | +# GitHub recommends pinning actions to a commit SHA. |
| 7 | +# To get a newer version, you will need to update the SHA. |
| 8 | +# You can also reference a tag or branch, but the action may change without warning. |
| 9 | + |
| 10 | +name: Publish Docker image |
| 11 | + |
| 12 | +on: |
| 13 | + release: |
| 14 | + types: [published] |
| 15 | + |
| 16 | +jobs: |
| 17 | + push_to_registry: |
| 18 | + name: Push Docker image to Docker Hub |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Check out the repo |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Log in to Docker Hub |
| 25 | + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a |
| 26 | + with: |
| 27 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 28 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 29 | + |
| 30 | + - name: Build and push Docker image |
| 31 | + if: github.ref == 'refs/heads/main' # Run the step only for the main branch |
| 32 | + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 |
| 33 | + with: |
| 34 | + context: . |
| 35 | + file: ./Dockerfile |
| 36 | + push: true |
| 37 | + tags: ${{ steps.meta.outputs.tags }} |
| 38 | + labels: ${{ steps.meta.outputs.labels }} |
| 39 | + |
| 40 | + - name: Build Docker image |
| 41 | + if: github.ref != 'refs/heads/main' # Run the step only for the main branch |
| 42 | + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 |
| 43 | + with: |
| 44 | + context: . |
| 45 | + file: ./Dockerfile |
| 46 | + push: false |
| 47 | + tags: ${{ steps.meta.outputs.tags }} |
| 48 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments