From 85fc8b4024f5d220e5a1eaaf4cf27f461a4e459f Mon Sep 17 00:00:00 2001 From: gamvo74 <45856534+gamvo74@users.noreply.github.com> Date: Sun, 22 Feb 2026 08:42:55 -0500 Subject: [PATCH] Add API publishing to GitHub Container Registry workflow Updated workflow to publish API Docker image to GitHub Container Registry. --- .github/workflows/ghcr-publish.yml | 92 ++++++++++++------------------ 1 file changed, 37 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ghcr-publish.yml b/.github/workflows/ghcr-publish.yml index 97fc855..2c545b9 100644 --- a/.github/workflows/ghcr-publish.yml +++ b/.github/workflows/ghcr-publish.yml @@ -1,55 +1,37 @@ -name: Publish to GitHub Container Registry - -on: - push: - branches: - - main - tags: - - 'v*' - pull_request: - branches: - - main - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - build-and-push: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + name: Publish API to GitHub Container Registry + + on: + push: + branches: + - main + + jobs: + build-and-push-api: + runs-on: ubuntu-latest + # This permission is necessary to allow the workflow to write to GitHub Packages. + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + # This tells Docker where to find your Dockerfile and code + context: ./apps/api + push: true + # This will tag the image with both 'latest' and 'main' + tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:main