From f688952ed82066203fbdc289c9706e497f3e9446 Mon Sep 17 00:00:00 2001 From: Robin Schanbacher Date: Thu, 3 Sep 2026 12:21:20 +0000 Subject: [PATCH 1/2] ci: refactor workflow to use standard actions --- .gitea/workflows/deploy.yaml | 114 ++++++++++++++++------------------- 1 file changed, 51 insertions(+), 63 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 6298d35..e9ecc0f 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -1,4 +1,4 @@ -name: Deploy Next.js via Docker +name: Build, Package & Release Next.js on: push: @@ -6,74 +6,62 @@ on: - main jobs: - deploy: + build-and-push: + name: Build & Push Docker Image runs-on: ubuntu-latest - container: - image: docker:latest steps: - - name: Checkout code - run: | - apk add --no-cache curl unzip - curl -L -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ - "http://172.17.0.1:3000/api/v1/repos/${{ github.repository }}/archive/main.zip" -o repo.zip - unzip repo.zip - mv PsalmTafel/* . 2>/dev/null || mv psalmtafel/* . 2>/dev/null || mv */* . 2>/dev/null - rm repo.zip + - name: Checkout Code + uses: actions/checkout@v4 - - name: Update Docker container + - name: Read Version from package.json + id: get_version run: | - echo "Building new Next.js Docker image..." - docker build -t psalmtafel-app . - - echo "Stopping old container if running..." - docker stop psalmtafel-container || true - docker rm psalmtafel-container || true - - echo "Starting new container..." - docker run -d \ - --name psalmtafel-container \ - -p 8443:3000 \ - --restart always \ - psalmtafel-app - - - name: Create release in Gitea - run: | - apk add --no-cache jq curl VERSION=$(jq -r '.version' package.json) - echo "Current version: v$VERSION" + echo "VERSION=$VERSION" >> $GITHUB_ENV - # Shell-kompatible Prüfung (funktioniert zuverlässig in Alpine/sh) - case "$VERSION" in - 0.*) - IS_PRERELEASE="true" - echo "Version starts with 0. Setting prerelease to true." - ;; - *) - IS_PRERELEASE="false" - echo "Setting prerelease to false." - ;; - esac + - name: Log in to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: 172.17.0.1:3000 + username: ${{ github.actor }} + password: ${{ secrets.GITEA_TOKEN }} - # Prüfen, ob das Release bereits existiert - HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ - -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ - "http://172.17.0.1:3000/api/v1/repos/${{ github.repository }}/releases/tags/v$VERSION") + - name: Build and Push Docker Image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + 172.17.0.1:3000/${{ github.repository }}:v${{ env.VERSION }} + 172.17.0.1:3000/${{ github.repository }}:latest - if [ "$HTTP_STATUS" -eq 404 ]; then - echo "Creating new release v$VERSION..." - # Gitea erstellt bei diesem Call automatisch auch den Tag v$VERSION auf 'main' - curl -X POST \ - -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ - -H "Content-Type: application/json" \ - -d "{ - \"tag_name\": \"v$VERSION\", - \"target_commitish\": \"main\", - \"name\": \"Release v$VERSION\", - \"body\": \"Automated release for version v$VERSION\", - \"draft\": false, - \"prerelease\": $IS_PRERELEASE - }" \ - "http://172.17.0.1:3000/api/v1/repos/${{ github.repository }}/releases" + create-release: + name: Create Gitea Release + needs: build-and-push + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Read Version from package.json + id: get_version + run: | + VERSION=$(jq -r '.version' package.json) + echo "VERSION=$VERSION" >> $GITHUB_ENV + + if [[ "$VERSION" == 0.* ]]; then + echo "PRERELEASE=true" >> $GITHUB_ENV else - echo "Release v$VERSION already exists. Skipping creation." - fi \ No newline at end of file + echo "PRERELEASE=false" >> $GITHUB_ENV + fi + + - name: Create Release in Gitea + uses: gitea/release-action@v1 + with: + state: "main" + tag: "v${{ env.VERSION }}" + name: "Release v${{ env.VERSION }}" + body: "Automated release for version v${{ env.VERSION }}" + prerelease: ${{ env.PRERELEASE == 'true' }} + env: + GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} \ No newline at end of file -- 2.54.1 From 4b587b543c7d3ff3e04c6b36c1ef8a64760ce2c9 Mon Sep 17 00:00:00 2001 From: Robin Schanbacher Date: Thu, 3 Sep 2026 12:22:44 +0000 Subject: [PATCH 2/2] ci: refactor workflow with docker actions and gitea release api --- .gitea/workflows/deploy.yaml | 41 ++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index e9ecc0f..ef681fe 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -14,7 +14,6 @@ jobs: uses: actions/checkout@v4 - name: Read Version from package.json - id: get_version run: | VERSION=$(jq -r '.version' package.json) echo "VERSION=$VERSION" >> $GITHUB_ENV @@ -43,25 +42,35 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 - - name: Read Version from package.json - id: get_version + - name: Create Release via Gitea API run: | VERSION=$(jq -r '.version' package.json) - echo "VERSION=$VERSION" >> $GITHUB_ENV if [[ "$VERSION" == 0.* ]]; then - echo "PRERELEASE=true" >> $GITHUB_ENV + PRERELEASE="true" else - echo "PRERELEASE=false" >> $GITHUB_ENV + PRERELEASE="false" fi - - name: Create Release in Gitea - uses: gitea/release-action@v1 - with: - state: "main" - tag: "v${{ env.VERSION }}" - name: "Release v${{ env.VERSION }}" - body: "Automated release for version v${{ env.VERSION }}" - prerelease: ${{ env.PRERELEASE == 'true' }} - env: - GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} \ No newline at end of file + # Prüfen, ob der Release bereits existiert + HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + "http://172.17.0.1:3000/api/v1/repos/${{ github.repository }}/releases/tags/v$VERSION") + + if [ "$HTTP_STATUS" -eq 404 ]; then + echo "Creating release v$VERSION in Gitea..." + curl -X POST \ + -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"v$VERSION\", + \"target_commitish\": \"main\", + \"name\": \"Release v$VERSION\", + \"body\": \"Automated release for version v$VERSION\", + \"draft\": false, + \"prerelease\": $PRERELEASE + }" \ + "http://172.17.0.1:3000/api/v1/repos/${{ github.repository }}/releases" + else + echo "Release v$VERSION exists already. Skipping." + fi \ No newline at end of file -- 2.54.1