|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - Dockerfile |
| 9 | + - .github/workflows/build.yml |
| 10 | + - root/** |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + paths: |
| 15 | + - Dockerfile |
| 16 | + - .github/workflows/build.yml |
| 17 | + - root/** |
| 18 | + repository_dispatch: |
| 19 | + types: |
| 20 | + - upstream_image_update |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +jobs: |
| 24 | + docker: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + permissions: |
| 27 | + packages: write |
| 28 | + env: |
| 29 | + TITLE: Red-Dashboard |
| 30 | + GHCR_SLUG: ghcr.io/phasecorex/red-dashboard |
| 31 | + DOCK_SLUG: docker.io/phasecorex/red-dashboard |
| 32 | + steps: |
| 33 | + - |
| 34 | + name: Checkout |
| 35 | + uses: actions/checkout@v4 |
| 36 | + - |
| 37 | + name: Docker meta |
| 38 | + id: meta |
| 39 | + uses: docker/metadata-action@v5 |
| 40 | + with: |
| 41 | + images: | |
| 42 | + ${{ env.GHCR_SLUG }} |
| 43 | + ${{ env.DOCK_SLUG }} |
| 44 | + labels: | |
| 45 | + maintainer=${{ github.repository_owner }} |
| 46 | + org.opencontainers.image.vendor=${{ github.repository_owner }} |
| 47 | + org.opencontainers.image.title=${{ env.TITLE }} |
| 48 | + - |
| 49 | + name: Set up QEMU |
| 50 | + uses: docker/setup-qemu-action@v3 |
| 51 | + - |
| 52 | + name: Set up Docker Buildx |
| 53 | + uses: docker/setup-buildx-action@v3 |
| 54 | + - |
| 55 | + name: Login to GitHub Container Registry |
| 56 | + if: github.event_name != 'pull_request' |
| 57 | + uses: docker/login-action@v3 |
| 58 | + with: |
| 59 | + registry: ghcr.io |
| 60 | + username: ${{ github.repository_owner }} |
| 61 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + - |
| 63 | + name: Login to DockerHub |
| 64 | + if: github.event_name != 'pull_request' |
| 65 | + uses: docker/login-action@v3 |
| 66 | + with: |
| 67 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 68 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 69 | + - |
| 70 | + name: Build and push |
| 71 | + uses: docker/build-push-action@v5 |
| 72 | + with: |
| 73 | + platforms: | |
| 74 | + linux/amd64 |
| 75 | + linux/arm/v7 |
| 76 | + linux/arm64 |
| 77 | + push: ${{ github.event_name != 'pull_request' }} |
| 78 | + tags: | |
| 79 | + ${{ env.GHCR_SLUG }}:latest |
| 80 | + ${{ env.DOCK_SLUG }}:latest |
| 81 | + cache-from: | |
| 82 | + ${{ env.GHCR_SLUG }}:latest |
| 83 | + labels: ${{ steps.meta.outputs.labels }} |
| 84 | + - |
| 85 | + name: Check manifest |
| 86 | + if: github.event_name != 'pull_request' |
| 87 | + run: | |
| 88 | + docker buildx imagetools inspect ${{ env.GHCR_SLUG }}:latest |
| 89 | + docker buildx imagetools inspect ${{ env.DOCK_SLUG }}:latest |
| 90 | + - |
| 91 | + name: Check pull |
| 92 | + if: github.event_name != 'pull_request' |
| 93 | + run: | |
| 94 | + docker pull ${{ env.GHCR_SLUG }}:latest |
| 95 | + docker image inspect ${{ env.GHCR_SLUG }}:latest |
| 96 | + docker pull ${{ env.DOCK_SLUG }}:latest |
| 97 | + docker image inspect ${{ env.DOCK_SLUG }}:latest |
0 commit comments