From a3c90d462887593b38fc9c19569b7fcd676aa3d0 Mon Sep 17 00:00:00 2001 From: Lobo Date: Sat, 28 Mar 2026 10:41:20 +0100 Subject: [PATCH] Changed wokflow --- .forgejo/workflows/docker-publish.yml | 28 ----------- .gitea/workflows/docker-publish.yml | 72 +++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 28 deletions(-) delete mode 100644 .forgejo/workflows/docker-publish.yml create mode 100644 .gitea/workflows/docker-publish.yml diff --git a/.forgejo/workflows/docker-publish.yml b/.forgejo/workflows/docker-publish.yml deleted file mode 100644 index 25cf14c..0000000 --- a/.forgejo/workflows/docker-publish.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Build and Publish Docker Image - -on: - push: - branches: - - main - -jobs: - build-and-push: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Log in to Codeberg Container Registry - uses: docker/login-action@v3 - with: - registry: codeberg.org - username: ${{ github.repository_owner }} - # Requires a generated Application Token from your Codeberg settings saved as a repository secret - password: ${{ secrets.CODEBERG_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: codeberg.org/${{ github.repository }}:latest \ No newline at end of file diff --git a/.gitea/workflows/docker-publish.yml b/.gitea/workflows/docker-publish.yml new file mode 100644 index 0000000..5ef57fc --- /dev/null +++ b/.gitea/workflows/docker-publish.yml @@ -0,0 +1,72 @@ +name: Build, Test & Push Frontend + +# Trigger the workflow +on: + push: + branches: + - main + +jobs: + # ------------------------------------------------------------------ + # JOB 1: Code integrity and quality gates (CI) + # ------------------------------------------------------------------ + quality-check: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '24' + cache: 'npm' + + - name: Install Dependencies + run: npm ci + + # Run ESLint if configured in package.json + - name: Lint & Type Check + run: npm run lint --if-present + + # Build the Vite React application + - name: Build Production + run: npm run build + + # ------------------------------------------------------------------ + # JOB 2: Docker Build & Push (CD) + # Runs only if 'quality-check' is successful and we are on branch main + # ------------------------------------------------------------------ + docker: + needs: quality-check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Prepare tag + id: prep + shell: bash + run: | + # Sanitize branch name for valid Docker tags + BRANCH="${GITHUB_REF_NAME}" + BRANCH="${BRANCH//\//-}" + BRANCH="$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]')" + echo "branch=$BRANCH" >> "$GITHUB_OUTPUT" + echo "sha=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT" + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build & Push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/tobeplayed-frontend:${{ steps.prep.outputs.branch }} + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/tobeplayed-frontend:${{ steps.prep.outputs.branch }}-${{ steps.prep.outputs.sha }} + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/tobeplayed-frontend:latest \ No newline at end of file