diff --git a/.github/workflows/admin-web-docker.yml b/.github/workflows/admin-web-docker.yml new file mode 100644 index 0000000..383d5da --- /dev/null +++ b/.github/workflows/admin-web-docker.yml @@ -0,0 +1,110 @@ +# ============================================================================= +# TabataGo — Admin Web Docker Build & Push to Gitea Container Registry +# ============================================================================= +# +# Gitea Registry URL: gitea.1000co.fr/millianlmx/tabatago/admin-web +# +# Required secrets: +# GITEA_DOCKER_TOKEN — PAT with read:package + write:package scopes +# GITEA_DOCKER_USER — Gitea username for Docker login (default: millianlmx) +# ============================================================================= + +name: Admin Web — Docker Build & Push + +on: + push: + branches: [main] + paths: + - 'admin-web/**' + - '.github/workflows/admin-web-docker.yml' + pull_request: + branches: [main] + paths: + - 'admin-web/**' + - '.github/workflows/admin-web-docker.yml' + +env: + REGISTRY: gitea.1000co.fr + IMAGE_NAME: ${{ github.repository }}/admin-web + +jobs: + build-and-push: + name: Build & Push Docker Image + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # ── Metadata: image tags & labels ── + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=sha,prefix=,format=short + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + labels: | + org.opencontainers.image.title=TabataGo Admin Web + org.opencontainers.image.description=Next.js admin dashboard for TabataGo + org.opencontainers.image.vendor=Millian LMX + + # ── Login to Gitea Container Registry ── + - name: Login to Gitea Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.GITEA_DOCKER_USER || 'millianlmx' }} + password: ${{ secrets.GITEA_DOCKER_TOKEN }} + + # ── Build & Push ── + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: admin-web + file: admin-web/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64 + + # ── PR comment with image info ── + - name: Post PR image info + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + const sha = context.sha.substring(0, 7); + const image = `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.pull_request.number }}`; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: [ + '## 🐳 Docker Image Built', + '', + '| | |', + '|---|---|', + `| **Image** | \`${image}\` |`, + `| **Commit** | \`${sha}\` |`, + '', + 'Pull the image:', + '```bash', + `docker pull ${image}`, + '```', + ].join('\n') + });