Merge pull request #220 from bahlo/arne/fix-docker #733
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
push: | |
tags: | |
- "*" | |
branches: | |
- main | |
pull_request: | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- uses: pdm-project/setup-pdm@v3 | |
- run: pdm sync -d | |
- run: pdm run ruff check | |
- run: pdm run ruff format --check | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- uses: pdm-project/setup-pdm@v3 | |
- run: pdm sync -d | |
- run: pdm run pytest | |
docker: | |
name: Docker | |
runs-on: ubuntu-latest | |
needs: | |
- check | |
- test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log into docker | |
run: docker login ghcr.io -u bahlo -p "${{ secrets.GITHUB_TOKEN }}" | |
- name: Build docker container | |
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags') | |
run: docker build -t ghcr.io/bahlo/ing-ynab:branch . | |
- name: Build and publish docker latest | |
if: github.ref == 'refs/heads/main' | |
run: | | |
docker build -t ghcr.io/bahlo/ing-ynab:latest . | |
docker push ghcr.io/bahlo/ing-ynab:latest | |
- name: Build and publish docker image | |
if: startsWith(github.ref, 'refs/tags') | |
run: | | |
export TAG=$(echo "${{ github.ref }}" | sed 's/^refs\/tags\/v//g') | |
docker build -t ghcr.io/bahlo/ing-ynab:$TAG . | |
docker push ghcr.io/bahlo/ing-ynab:$TAG | |
publish: | |
name: Publish on PyPi | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags') | |
needs: | |
- check | |
- test | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- uses: pdm-project/setup-pdm@v3 | |
- run: pdm publish | |
env: | |
PDM_PUBLISH_USERNAME: "__token__" | |
PDM_PUBLISH_PASSWORD: "${{ secrets.PYPI_TOKEN }}" |