name: Deploy Next.js via Docker on: push: branches: - main jobs: deploy: 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: Update Docker container 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 VERSION=$(jq -r '.version' package.json) echo "Current version: v$VERSION" 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 new release v$VERSION..." 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\": false }" \ "http://172.17.0.1:3000/api/v1/repos/${{ github.repository }}/releases" else echo "Release v$VERSION already exists. Skipping creation." fi