From cb3703ec3a511548c4fb29dadb323aeebe481914 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 25 Jan 2026 02:28:16 +0100 Subject: [PATCH] Use working Gitea workflow format with ubuntu-latest --- .gitea/workflows/build.yml | 75 +++++++++++++++++++++---------------- .github/workflows/build.yml | 75 +++++++++++++++++++++---------------- 2 files changed, 84 insertions(+), 66 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 2ea1455..1e2d3b5 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,50 +1,59 @@ -name: Build and Deploy +name: Build and Push Docker Image on: push: branches: - main + - master + tags: + - 'v*' pull_request: branches: - main + - master + +env: + REGISTRY: code.letsbe.solutions + IMAGE_NAME: letsbe/monacousa-portal jobs: build: - runs-on: ubuntu + runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout repository uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 with: - node-version: '20' + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} - - name: Install dependencies - run: npm ci --legacy-peer-deps + - name: Extract metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest,enable={{is_default_branch}} - - name: Build - run: npm run build - env: - PUBLIC_SUPABASE_URL: https://api.portal.monacousa.org - PUBLIC_SUPABASE_ANON_KEY: placeholder - SUPABASE_SERVICE_ROLE_KEY: placeholder - - - name: Build Docker image - run: | - docker build -t monacousa-portal:${{ gitea.sha }} \ - --build-arg PUBLIC_SUPABASE_URL=https://api.portal.monacousa.org \ - --build-arg PUBLIC_SUPABASE_ANON_KEY=placeholder \ - --build-arg SUPABASE_SERVICE_ROLE_KEY=placeholder \ - . - - - name: Test container starts - run: | - docker run -d --name test-portal \ - -e PUBLIC_SUPABASE_URL=https://api.portal.monacousa.org \ - -e PUBLIC_SUPABASE_ANON_KEY=placeholder \ - monacousa-portal:${{ gitea.sha }} - sleep 5 - docker logs test-portal - docker stop test-portal - docker rm test-portal + - 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 }} + build-args: | + PUBLIC_SUPABASE_URL=https://api.portal.monacousa.org + PUBLIC_SUPABASE_ANON_KEY=placeholder + SUPABASE_SERVICE_ROLE_KEY=placeholder diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ea1455..1e2d3b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,50 +1,59 @@ -name: Build and Deploy +name: Build and Push Docker Image on: push: branches: - main + - master + tags: + - 'v*' pull_request: branches: - main + - master + +env: + REGISTRY: code.letsbe.solutions + IMAGE_NAME: letsbe/monacousa-portal jobs: build: - runs-on: ubuntu + runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout repository uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 with: - node-version: '20' + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} - - name: Install dependencies - run: npm ci --legacy-peer-deps + - name: Extract metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest,enable={{is_default_branch}} - - name: Build - run: npm run build - env: - PUBLIC_SUPABASE_URL: https://api.portal.monacousa.org - PUBLIC_SUPABASE_ANON_KEY: placeholder - SUPABASE_SERVICE_ROLE_KEY: placeholder - - - name: Build Docker image - run: | - docker build -t monacousa-portal:${{ gitea.sha }} \ - --build-arg PUBLIC_SUPABASE_URL=https://api.portal.monacousa.org \ - --build-arg PUBLIC_SUPABASE_ANON_KEY=placeholder \ - --build-arg SUPABASE_SERVICE_ROLE_KEY=placeholder \ - . - - - name: Test container starts - run: | - docker run -d --name test-portal \ - -e PUBLIC_SUPABASE_URL=https://api.portal.monacousa.org \ - -e PUBLIC_SUPABASE_ANON_KEY=placeholder \ - monacousa-portal:${{ gitea.sha }} - sleep 5 - docker logs test-portal - docker stop test-portal - docker rm test-portal + - 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 }} + build-args: | + PUBLIC_SUPABASE_URL=https://api.portal.monacousa.org + PUBLIC_SUPABASE_ANON_KEY=placeholder + SUPABASE_SERVICE_ROLE_KEY=placeholder