|
| 1 | +name: Publish GHCR Images |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +concurrency: |
| 7 | + group: publish-ghcr-${{ github.ref }} |
| 8 | + cancel-in-progress: true |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + packages: write |
| 13 | + |
| 14 | +env: |
| 15 | + REGISTRY: ghcr.io |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-and-push-backend: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + digest: ${{ steps.build.outputs.digest }} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Compute image prefix |
| 26 | + id: meta |
| 27 | + run: echo "prefix=${REGISTRY}/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" |
| 28 | + |
| 29 | + - name: Log in to GHCR |
| 30 | + uses: docker/login-action@v3 |
| 31 | + with: |
| 32 | + registry: ${{ env.REGISTRY }} |
| 33 | + username: ${{ github.actor }} |
| 34 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v3 |
| 38 | + |
| 39 | + - name: Build and push backend image |
| 40 | + id: build |
| 41 | + uses: docker/build-push-action@v6 |
| 42 | + with: |
| 43 | + context: ./backend |
| 44 | + push: true |
| 45 | + tags: | |
| 46 | + ${{ steps.meta.outputs.prefix }}/dashboard-backend:latest |
| 47 | + ${{ steps.meta.outputs.prefix }}/dashboard-backend:${{ github.sha }} |
| 48 | +
|
| 49 | + build-and-push-dashboard: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + outputs: |
| 52 | + digest: ${{ steps.build.outputs.digest }} |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Compute image prefix |
| 57 | + id: meta |
| 58 | + run: echo "prefix=${REGISTRY}/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" |
| 59 | + |
| 60 | + - name: Log in to GHCR |
| 61 | + uses: docker/login-action@v3 |
| 62 | + with: |
| 63 | + registry: ${{ env.REGISTRY }} |
| 64 | + username: ${{ github.actor }} |
| 65 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + |
| 67 | + - name: Set up Docker Buildx |
| 68 | + uses: docker/setup-buildx-action@v3 |
| 69 | + |
| 70 | + - name: Build and push dashboard image |
| 71 | + id: build |
| 72 | + uses: docker/build-push-action@v6 |
| 73 | + with: |
| 74 | + context: . |
| 75 | + file: ./dashboard/Dockerfile |
| 76 | + push: true |
| 77 | + tags: | |
| 78 | + ${{ steps.meta.outputs.prefix }}/dashboard-frontend:latest |
| 79 | + ${{ steps.meta.outputs.prefix }}/dashboard-frontend:${{ github.sha }} |
| 80 | +
|
| 81 | + build-and-push-proxy: |
| 82 | + runs-on: ubuntu-latest |
| 83 | + outputs: |
| 84 | + digest: ${{ steps.build.outputs.digest }} |
| 85 | + steps: |
| 86 | + - uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Compute image prefix |
| 89 | + id: meta |
| 90 | + run: echo "prefix=${REGISTRY}/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" |
| 91 | + |
| 92 | + - name: Log in to GHCR |
| 93 | + uses: docker/login-action@v3 |
| 94 | + with: |
| 95 | + registry: ${{ env.REGISTRY }} |
| 96 | + username: ${{ github.actor }} |
| 97 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + |
| 99 | + - name: Set up Docker Buildx |
| 100 | + uses: docker/setup-buildx-action@v3 |
| 101 | + |
| 102 | + - name: Build and push proxy image |
| 103 | + id: build |
| 104 | + uses: docker/build-push-action@v6 |
| 105 | + with: |
| 106 | + context: ./proxy |
| 107 | + push: true |
| 108 | + tags: | |
| 109 | + ${{ steps.meta.outputs.prefix }}/dashboard-proxy:latest |
| 110 | + ${{ steps.meta.outputs.prefix }}/dashboard-proxy:${{ github.sha }} |
| 111 | +
|
| 112 | + verify: |
| 113 | + if: always() |
| 114 | + needs: |
| 115 | + - build-and-push-backend |
| 116 | + - build-and-push-dashboard |
| 117 | + - build-and-push-proxy |
| 118 | + runs-on: ubuntu-latest |
| 119 | + steps: |
| 120 | + - name: Image publish summary |
| 121 | + run: | |
| 122 | + echo "### Published GHCR Images" >> "$GITHUB_STEP_SUMMARY" |
| 123 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 124 | + echo "| Image | Digest |" >> "$GITHUB_STEP_SUMMARY" |
| 125 | + echo "| ----- | ------ |" >> "$GITHUB_STEP_SUMMARY" |
| 126 | + echo "| dashboard-backend | \`${{ needs.build-and-push-backend.outputs.digest }}\` |" >> "$GITHUB_STEP_SUMMARY" |
| 127 | + echo "| dashboard-frontend | \`${{ needs.build-and-push-dashboard.outputs.digest }}\` |" >> "$GITHUB_STEP_SUMMARY" |
| 128 | + echo "| dashboard-proxy | \`${{ needs.build-and-push-proxy.outputs.digest }}\` |" >> "$GITHUB_STEP_SUMMARY" |
0 commit comments