- Replaced vars.REPOSITORY_TOKEN with secrets.REPOSITORY_TOKEN for Gitea registry login. - This improves security by storing the token as a secret. - Ensures the token is not exposed in the workflow file.
92 lines
2.3 KiB
YAML
92 lines
2.3 KiB
YAML
name: CI + Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install uv
|
|
run: |
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
|
|
- name: Run Ruff
|
|
run: |
|
|
uv venv .venv
|
|
source .venv/bin/activate
|
|
uv run ruff check
|
|
uv run ruff format --check
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
needs: lint
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install uv
|
|
run: |
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
|
|
- name: Run Tests
|
|
run: |
|
|
uv venv .venv
|
|
source .venv/bin/activate
|
|
uv run pytest -v --cov=. --cov-report=xml
|
|
|
|
- name: Upload to Codecov
|
|
run: bash <(curl -s https://codecov.io/bash)
|
|
|
|
deploy_to_pypi:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: github.ref == 'refs/heads/master'
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Install uv
|
|
run: |
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
|
|
- name: Publish to PyPI
|
|
env:
|
|
TWINE_USERNAME: __token__
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
run: |
|
|
uv venv .venv
|
|
source .venv/bin/activate
|
|
uv pip install build twine
|
|
uv run python -m build
|
|
uv run python -m twine upload dist/*
|
|
|
|
deploy_to_registries:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
if: github.ref == 'refs/heads/master'
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Log in to DockerHub
|
|
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
|
|
|
|
- name: Log in to Gitea Registry
|
|
run: echo "${{ secrets.REPOSITORY_TOKEN }}" | docker login git.rogs.me -u rogs --password-stdin
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Build and push to both DockerHub and Gitea
|
|
run: |
|
|
docker buildx build --push \
|
|
--tag rogsme/subscleaner:latest \
|
|
--tag git.rogs.me/rogs/subscleaner:latest \
|
|
.
|