Compare commits
4 commits
3901db9f76
...
a3fd5f212e
| Author | SHA1 | Date | |
|---|---|---|---|
| a3fd5f212e | |||
| 80ba98478b | |||
| 31a5808b81 | |||
| 57c729f991 |
4 changed files with 38 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
name: Build and Push Docker Image to Forgejo Registry
|
name: Build, Push, and Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -33,6 +33,8 @@ jobs:
|
||||||
images: ${{ gitea.server_url }}/${{ gitea.repository }}
|
images: ${{ gitea.server_url }}/${{ gitea.repository }}
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/main' || gitea.ref == 'refs/heads/master' }}
|
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=
|
type=sha,prefix=
|
||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image
|
||||||
|
|
@ -44,3 +46,35 @@ jobs:
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
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
|
||||||
|
}"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ WORKDIR /app
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
PORT=8000 \
|
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 .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import requests
|
||||||
|
|
||||||
# Default HTTP User-Agent adhering to Wikimedia API policy
|
# Default HTTP User-Agent adhering to Wikimedia API policy
|
||||||
DEFAULT_USER_AGENT = (
|
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
|
# Per-request HTTP timeout in seconds
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ services:
|
||||||
- "${PORT:-8000}:8000"
|
- "${PORT:-8000}:8000"
|
||||||
environment:
|
environment:
|
||||||
- PORT=8000
|
- 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:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "python -c 'import urllib.request; urllib.request.urlopen(\"http://localhost:8000/\")'"]
|
test: ["CMD-SHELL", "python -c 'import urllib.request; urllib.request.urlopen(\"http://localhost:8000/\")'"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
|
|
|
||||||
Reference in a new issue