From f155a7952a8e6b51e719dfe0c784bd8b53c83bbd Mon Sep 17 00:00:00 2001 From: hwinkel Date: Sat, 9 May 2026 12:32:36 +0200 Subject: [PATCH] feat: split Gitea workflow into test/build/push jobs --- .gitea/workflows/build.yml | 98 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 917d61d..4689df6 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -10,10 +10,9 @@ env: IMAGE_NAME: ${{ gitea.repository }} jobs: - build: + test: permissions: contents: read - packages: write runs-on: ubuntu-latest steps: @@ -32,6 +31,26 @@ jobs: - name: Run tests run: npm run test + build: + permissions: + contents: read + packages: write + needs: test + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + + - name: Install dependencies + run: npm ci + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -51,10 +70,79 @@ jobs: type=sha,prefix=,format=short type=raw,value=latest,enable={{is_default_branch}} - - name: Build and push + - name: Build and load Docker image uses: docker/build-push-action@v6 with: context: . - push: true + load: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + + - name: Save Docker image + run: | + mkdir -p ./docker-image + IMAGE_ID=$(docker images -q ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest) + docker save $IMAGE_ID -o ./docker-image/image.tar + + - name: Upload Docker image + uses: actions/upload-artifact@v4 + with: + name: docker-image + path: ./docker-image/image.tar + + push: + permissions: + contents: read + packages: write + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Download Docker image artifact + uses: actions/download-artifact@v4 + with: + name: docker-image + path: ./docker-image + + - name: Load Docker image + run: | + IMAGE_ID=$(docker load -i ./docker-image/image.tar --format '{{.ID}}') + echo "Loaded image: $IMAGE_ID" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ gitea.repository_owner }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha,prefix=,format=short + type=raw,value=latest,enable={{is_default_branch}} + + - name: Push Docker image + uses: docker/build-push-action@v6 + with: + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: true \ No newline at end of file