|
| 1 | +name: Publish Docker image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main", "master" ] |
| 6 | + tags: [ 'v*.*.*' ] |
| 7 | + pull_request: |
| 8 | + branches: [ "main", "master" ] |
| 9 | + |
| 10 | +env: |
| 11 | + IMAGE_NAME: traefik-log-processor |
| 12 | + DOCKERHUB_IMAGE: hhftechnology/traefik-log-processor |
| 13 | + GHCR_IMAGE: ghcr.io/hhftechnology/traefik-log-processor |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-push: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + packages: write |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up QEMU |
| 27 | + uses: docker/setup-qemu-action@v3 |
| 28 | + |
| 29 | + - name: Set up Docker Buildx |
| 30 | + uses: docker/setup-buildx-action@v3 |
| 31 | + |
| 32 | + - name: Log in to Docker Hub |
| 33 | + uses: docker/login-action@v3 |
| 34 | + with: |
| 35 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 36 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Log in to GitHub Container Registry |
| 39 | + uses: docker/login-action@v3 |
| 40 | + with: |
| 41 | + registry: ghcr.io |
| 42 | + username: ${{ github.actor }} |
| 43 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + - name: Extract metadata (tags, labels) for Docker |
| 46 | + id: meta |
| 47 | + uses: docker/metadata-action@v5 |
| 48 | + with: |
| 49 | + images: | |
| 50 | + ${{ env.DOCKERHUB_IMAGE }} |
| 51 | + ${{ env.GHCR_IMAGE }} |
| 52 | + tags: | |
| 53 | + type=ref,event=branch |
| 54 | + type=ref,event=pr |
| 55 | + type=semver,pattern={{version}} |
| 56 | + type=semver,pattern={{major}}.{{minor}} |
| 57 | + type=semver,pattern={{major}} |
| 58 | + type=sha,format=long |
| 59 | + type=raw,value=latest,enable={{is_default_branch}} |
| 60 | +
|
| 61 | + - name: Build and push Docker image |
| 62 | + uses: docker/build-push-action@v5 |
| 63 | + with: |
| 64 | + context: . |
| 65 | + push: ${{ github.event_name != 'pull_request' }} |
| 66 | + tags: ${{ steps.meta.outputs.tags }} |
| 67 | + labels: ${{ steps.meta.outputs.labels }} |
| 68 | + platforms: linux/amd64,linux/arm64 |
| 69 | + cache-from: type=gha |
| 70 | + cache-to: type=gha,mode=max |
0 commit comments