Compare commits

..

4 commits

4 changed files with 38 additions and 4 deletions

View file

@ -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
}"

View file

@ -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

View file

@ -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

View file

@ -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