Skip to content

Fix Docker environment configuration #11

Fix Docker environment configuration

Fix Docker environment configuration #11

Workflow file for this run

name: CI/CD
on:
push:
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test-build:
name: Test and Build
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --dev
- name: Lint with flake8
run: |
uv run flake8 github_backup/
- name: Check code formatting with black
run: |
uv run black --check github_backup/
- name: Test import
run: |
uv run python -c "import github_backup; print('Import successful')"
- name: Test CLI help
run: |
uv run github-backup --help
- name: Build package
if: matrix.python-version == '3.12'
run: uv build
- name: Upload build artifacts
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
docker:
name: GHCR Release
runs-on: ubuntu-latest
needs: test-build
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
name: PyPI Release
runs-on: ubuntu-latest
needs: test-build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v5
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}