Compare commits
2 Commits
03f26d7ac1
...
912f80966b
| Author | SHA1 | Date | |
|---|---|---|---|
| 912f80966b | |||
| d9dbcb5fd6 |
43
.github/workflows/ci.yml
vendored
43
.github/workflows/ci.yml
vendored
@@ -9,6 +9,8 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
env:
|
||||||
|
RUNNER_TOOL_CACHE: /toolcache
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -22,12 +24,17 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Locate pip cache directory
|
||||||
|
id: pip-cache-dir
|
||||||
|
run: echo "dir=$(python -m pip cache dir)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Cache pip
|
- name: Cache pip
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pip
|
path: ${{ steps.pip-cache-dir.outputs.dir }}
|
||||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
key: ${{ runner.os }}-py-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
|
${{ runner.os }}-py-${{ matrix.python-version }}-pip-
|
||||||
${{ runner.os }}-pip-
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -47,18 +54,40 @@ jobs:
|
|||||||
# path: tests
|
# path: tests
|
||||||
|
|
||||||
build-image:
|
build-image:
|
||||||
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: test
|
needs: test
|
||||||
|
env:
|
||||||
|
DEFAULT_BRANCH: main
|
||||||
|
REGISTRY_URL: ${{ secrets.REGISTRY_URL }}
|
||||||
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Collect workflow metadata
|
||||||
|
id: meta
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
ref_name="${GITHUB_REF_NAME:-${GITHUB_REF##*/}}"
|
||||||
|
event_name="${GITHUB_EVENT_NAME:-}"
|
||||||
|
sha="${GITHUB_SHA:-}"
|
||||||
|
|
||||||
|
if [ "$ref_name" = "${DEFAULT_BRANCH:-main}" ]; then
|
||||||
|
echo "on_default=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "on_default=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "ref_name=$ref_name" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "event_name=$event_name" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "sha=$sha" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Set up QEMU and Buildx
|
- name: Set up QEMU and Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to registry (best-effort)
|
- name: Log in to registry (best-effort)
|
||||||
if: ${{ github.ref == 'refs/heads/main' }}
|
if: ${{ steps.meta.outputs.on_default == 'true' }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
@@ -71,14 +100,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
push: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && (secrets.REGISTRY_URL != '' && secrets.REGISTRY_USERNAME != '' && secrets.REGISTRY_PASSWORD != '') }}
|
push: ${{ steps.meta.outputs.on_default == 'true' && steps.meta.outputs.event_name != 'pull_request' && (secrets.REGISTRY_URL != '' && secrets.REGISTRY_USERNAME != '' && secrets.REGISTRY_PASSWORD != '') }}
|
||||||
tags: |
|
tags: |
|
||||||
${{ secrets.REGISTRY_URL }}/allucanget/contact.allucanget.biz:latest
|
${{ secrets.REGISTRY_URL }}/allucanget/contact.allucanget.biz:latest
|
||||||
${{ secrets.REGISTRY_URL }}/allucanget/contact.allucanget.biz:${{ github.sha }}
|
${{ secrets.REGISTRY_URL }}/allucanget/contact.allucanget.biz:${{ steps.meta.outputs.sha }}
|
||||||
|
|
||||||
- name: Upload built image metadata
|
- name: Upload built image metadata
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: image-build-info
|
name: image-build-info
|
||||||
path: .
|
path: .
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ SMTP integration tests are skipped unless `RUN_SMTP_INTEGRATION_TEST=1` and vali
|
|||||||
|
|
||||||
## Deployment Notes
|
## Deployment Notes
|
||||||
|
|
||||||
- A single GitHub Actions workflow (`ci.yml`) runs pytest on every push/pull request, uploads the test directory as an artifact, and optionally builds the Docker image.
|
- A single Gitea Actions workflow (`.github/workflows/ci.yml`) exercises pytest on each push, pull request, or manual dispatch, then conditionally builds the Docker image.
|
||||||
- On pushes to `main` (or manual dispatch) the workflow builds the container and, when registry credentials are available, pushes tags to `git.allucanget.biz`.
|
- When the default branch (`main`) runs and registry secrets (`REGISTRY_URL`, `REGISTRY_USERNAME`, `REGISTRY_PASSWORD`) are configured in Gitea, the workflow logs in and pushes both `latest` and commit-specific image tags.
|
||||||
|
- Import or mirror the required reusable actions (`actions/checkout`, `actions/setup-python`, and the Docker actions) into your Gitea instance so that the workflow can resolve them.
|
||||||
- For production use, deploy the container behind a load balancer or reverse proxy and supply the appropriate environment variables.
|
- For production use, deploy the container behind a load balancer or reverse proxy and supply the appropriate environment variables.
|
||||||
|
|||||||
Reference in New Issue
Block a user