Add CI/CD workflow for automated deployments in Gitea
Some checks failed
Some checks failed
- Introduces a GitHub Actions workflow for CI/CD. - Replaces GitLab CI configuration with GitHub Actions. - Adds linting, testing, PyPI deployment, DockerHub deployment, and Gitea deployment jobs. - Uses uv for consistent environment and dependency management. - Configures DockerHub and Gitea deployments using secrets and variables. - Removes GitLab CI configuration.
This commit is contained in:
parent
254e6b9c26
commit
ad437ce752
107
.gitea/workflows/ci.yml
Normal file
107
.gitea/workflows/ci.yml
Normal file
@ -0,0 +1,107 @@
|
||||
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
|
||||
uv pip install --system ruff
|
||||
|
||||
- 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 + build tools
|
||||
run: |
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
uv pip install --system build twine
|
||||
|
||||
- name: Publish to PyPI
|
||||
env:
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
||||
run: |
|
||||
uv venv .venv
|
||||
source .venv/bin/activate
|
||||
uv run python -m build
|
||||
uv run python -m twine upload dist/*
|
||||
|
||||
deploy_to_dockerhub:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [deploy_to_pypi]
|
||||
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: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Build and push to DockerHub
|
||||
run: |
|
||||
docker buildx build --push \
|
||||
--tag rogsme/subscleaner:latest \
|
||||
.
|
||||
|
||||
deploy_to_gitea:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [deploy_to_pypi]
|
||||
if: github.ref == 'refs/heads/master'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Log in to Gitea Registry
|
||||
run: echo "${{ vars.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 Gitea
|
||||
run: |
|
||||
docker buildx build --push \
|
||||
--tag git.rogs.me/rogs/subscleaner:latest \
|
||||
.
|
@ -18,51 +18,13 @@ lint:
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- uv run pytest -v --cov=. --cov-report=xml
|
||||
after_script:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
- uv run pytest
|
||||
artifacts:
|
||||
reports:
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: coverage.xml
|
||||
|
||||
deploy_to_pypi:
|
||||
stage: deploy
|
||||
only:
|
||||
refs:
|
||||
- master
|
||||
changes:
|
||||
- pyproject.toml
|
||||
except:
|
||||
- tags
|
||||
script:
|
||||
- uv add build twine
|
||||
- uv run python -m build
|
||||
- TWINE_USERNAME=__token__ TWINE_PASSWORD=$PYPI_PASSWORD uv run python -m twine upload dist/*
|
||||
|
||||
deploy_to_dockerhub:
|
||||
stage: deploy
|
||||
needs:
|
||||
- job: deploy_to_pypi
|
||||
optional: true
|
||||
only:
|
||||
refs:
|
||||
- master
|
||||
changes:
|
||||
- pyproject.toml
|
||||
- Dockerfile
|
||||
except:
|
||||
- tags
|
||||
image: docker:latest
|
||||
services:
|
||||
- docker:dind
|
||||
before_script:
|
||||
- docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
|
||||
- docker buildx create --use
|
||||
script:
|
||||
- docker buildx build --push --tag rogsme/subscleaner:latest .
|
||||
|
||||
deploy_to_gitlab:
|
||||
stage: deploy
|
||||
needs:
|
||||
|
Loading…
x
Reference in New Issue
Block a user