From 33785440c6d3a8ecf93f66971523c4794c5743bf Mon Sep 17 00:00:00 2001 From: dtinth-ampere-devbox Date: Sat, 31 Jan 2026 11:31:15 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7(CI)=20add=20GHCR=20workflow=20for?= =?UTF-8?q?=20forked=20repo=20testing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add workflow_dispatch-triggered workflow that builds and pushes images to GitHub Container Registry (ghcr.io). This allows forked repositories to build their own images for testing without requiring Docker Hub credentials. Images are tagged with branch names, semver tags, and commit SHA for easy testing of specific builds. Signed-off-by: dtinth on MBP M1 --- .github/workflows/ghcr.yml | 157 +++++++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 + 2 files changed, 158 insertions(+) create mode 100644 .github/workflows/ghcr.yml diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml new file mode 100644 index 00000000..3dd470b8 --- /dev/null +++ b/.github/workflows/ghcr.yml @@ -0,0 +1,157 @@ +name: Build and Push to GHCR +run-name: Build and Push to GHCR + +on: + workflow_dispatch: + push: + branches: + - 'main' + tags: + - 'v*' + +env: + DOCKER_USER: 1001:127 + REGISTRY: ghcr.io + +jobs: + build-and-push-backend: + runs-on: ubuntu-latest + if: github.event.repository.fork == true + permissions: + contents: read + packages: write + steps: + - + name: Checkout repository + uses: actions/checkout@v4 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}/backend + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + - + name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + target: backend-production + build-args: DOCKER_USER=${{ env.DOCKER_USER }}:-1000 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - + name: Cleanup Docker after build + if: always() + run: | + docker system prune -af + docker volume prune -f + + build-and-push-frontend: + runs-on: ubuntu-latest + if: github.event.repository.fork == true + permissions: + contents: read + packages: write + steps: + - + name: Checkout repository + uses: actions/checkout@v4 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}/frontend + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + - + name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./src/frontend/Dockerfile + target: frontend-production + build-args: | + DOCKER_USER=${{ env.DOCKER_USER }}:-1000 + PUBLISH_AS_MIT=false + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - + name: Cleanup Docker after build + if: always() + run: | + docker system prune -af + docker volume prune -f + + build-and-push-y-provider: + runs-on: ubuntu-latest + if: github.event.repository.fork == true + permissions: + contents: read + packages: write + steps: + - + name: Checkout repository + uses: actions/checkout@v4 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}/y-provider + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + - + name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./src/frontend/servers/y-provider/Dockerfile + target: y-provider + build-args: DOCKER_USER=${{ env.DOCKER_USER }}:-1000 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - + name: Cleanup Docker after build + if: always() + run: | + docker system prune -af + docker volume prune -f diff --git a/CHANGELOG.md b/CHANGELOG.md index a6e8d97c..0fe6a3d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to - ✨(frontend) Can print a doc #1832 - ✨(backend) manage reconciliation requests for user accounts #1878 +- 👷(CI) add GHCR workflow for forked repo testing #1851 ### Changed