|
| 1 | +name: Publish Docker Image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + ghcr: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + permissions: |
| 12 | + packages: write |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Set up QEMU |
| 19 | + uses: docker/setup-qemu-action@v3 |
| 20 | + |
| 21 | + - name: Set up Docker Buildx |
| 22 | + uses: docker/setup-buildx-action@v3 |
| 23 | + with: |
| 24 | + driver: docker-container |
| 25 | + |
| 26 | + - name: Login to GitHub Container Registry |
| 27 | + uses: docker/login-action@v2 |
| 28 | + with: |
| 29 | + registry: ghcr.io |
| 30 | + username: ${{ github.actor }} |
| 31 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Build and push Docker image to GHCR |
| 34 | + uses: docker/build-push-action@v3 |
| 35 | + with: |
| 36 | + context: . |
| 37 | + push: true |
| 38 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 39 | + tags: ghcr.io/${{ github.repository }}:latest |
| 40 | + |
| 41 | + dockerhub: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + |
| 44 | + steps: |
| 45 | + - name: Checkout repository |
| 46 | + if: vars.DOCKER_USERNAME != null |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Set up QEMU |
| 50 | + if: vars.DOCKER_USERNAME != null |
| 51 | + uses: docker/setup-qemu-action@v3 |
| 52 | + |
| 53 | + - name: Set up Docker Buildx |
| 54 | + if: vars.DOCKER_USERNAME != null |
| 55 | + uses: docker/setup-buildx-action@v3 |
| 56 | + with: |
| 57 | + driver: docker-container |
| 58 | + |
| 59 | + - name: Login to Docker Hub |
| 60 | + if: vars.DOCKER_USERNAME != null |
| 61 | + uses: docker/login-action@v2 |
| 62 | + with: |
| 63 | + username: ${{ vars.DOCKER_USERNAME }} |
| 64 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 65 | + |
| 66 | + - name: Build and push Docker image to Docker Hub |
| 67 | + if: vars.DOCKER_USERNAME != null |
| 68 | + uses: docker/build-push-action@v3 |
| 69 | + with: |
| 70 | + context: . |
| 71 | + push: true |
| 72 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 73 | + tags: ${{ github.repository }}:latest |
0 commit comments