diff --git a/.forgejo/workflows/build-push.yml b/.forgejo/workflows/build-push.yml index 673d9cd..3ee1c48 100644 --- a/.forgejo/workflows/build-push.yml +++ b/.forgejo/workflows/build-push.yml @@ -1,4 +1,4 @@ -name: Build and Push Docker Image to Forgejo Registry +name: Build, Push, and Release on: push: @@ -33,6 +33,8 @@ jobs: images: ${{ gitea.server_url }}/${{ gitea.repository }} tags: | type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/main' || gitea.ref == 'refs/heads/master' }} + type=ref,event=branch + type=ref,event=tag type=sha,prefix= - name: Build and Push Docker Image @@ -44,3 +46,35 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + + create-release: + needs: build-and-push + if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') || startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Create Release in Forgejo + run: | + if [ "${{ startsWith(github.ref, 'refs/tags/v') }}" = "true" ]; then + TAG_NAME="${GITHUB_REF#refs/tags/}" + RELEASE_NAME="Release ${TAG_NAME}" + else + TAG_NAME="v2.0.${{ github.run_number }}" + RELEASE_NAME="Phikipathia Release ${TAG_NAME}" + fi + + echo "Creating release ${RELEASE_NAME} with tag ${TAG_NAME}..." + + curl -s -X POST "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"${TAG_NAME}\", + \"target_commitish\": \"${{ github.sha }}\", + \"name\": \"${RELEASE_NAME}\", + \"body\": \"Phikipathia release for commit ${{ github.sha }}. Docker container images are published to the Forgejo Container Registry.\", + \"draft\": false, + \"prerelease\": false + }" diff --git a/Dockerfile b/Dockerfile index 4e9a9a7..b2e0e21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /app ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PORT=8000 \ - USER_AGENT="Phikipathia/1.0 (https://git.depeuter.dev/tdpeuter/2022ST-project-Phikipathia)" + USER_AGENT="Phikipathia/1.0 (https://git.depeuter.dev/tdpeuter/2022ST-project-Phikipathia; tibo@depeuter.dev)" COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt diff --git a/cgi-bin/scraper.py b/cgi-bin/scraper.py index a7fe6ca..c97c49e 100644 --- a/cgi-bin/scraper.py +++ b/cgi-bin/scraper.py @@ -18,7 +18,7 @@ import requests # Default HTTP User-Agent adhering to Wikimedia API policy DEFAULT_USER_AGENT = ( - "Phikipathia/1.0 (https://git.depeuter.dev/tdpeuter/2022ST-project-Phikipathia; contact@phikipathia.org)" + "Phikipathia/1.0 (https://git.depeuter.dev/tdpeuter/2022ST-project-Phikipathia; tibo@depeuter.dev)" ) # Per-request HTTP timeout in seconds diff --git a/docker-compose.yml b/docker-compose.yml index 57d3d5c..fbe4ee7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - "${PORT:-8000}:8000" environment: - PORT=8000 - - USER_AGENT=${USER_AGENT:-Phikipathia/1.0 (https://git.depeuter.dev/tdpeuter/2022ST-project-Phikipathia)} + - USER_AGENT=${USER_AGENT:-Phikipathia/1.0 (https://git.depeuter.dev/tdpeuter/2022ST-project-Phikipathia; tibo@depeuter.dev)} healthcheck: test: ["CMD-SHELL", "python -c 'import urllib.request; urllib.request.urlopen(\"http://localhost:8000/\")'"] interval: 30s