This repository has been archived on 2023-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
python-blog/.github/workflows/publish.yaml

65 lines
1.9 KiB
YAML

name: Build, publish & deploy
on:
push:
branches:
- master
jobs:
tests:
name: Python tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.1.13
- name: Install dependencies
run: poetry install
- name: Test
run: pytest --cov=. --cov-branch --cov-report term-missing:skip-covered
working-directory: ./src/
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: [tests]
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
push: true
tags: crocmagnon/blog:latest
cache-from: type=registry,ref=crocmagnon/blog:latest
cache-to: type=inline
platforms: linux/amd64
build-args: |
POETRY_OPTIONS=--no-dev
deploy:
name: Deploy new image
runs-on: ubuntu-latest
needs: [push_to_registry]
steps:
- name: Deploy
run: |
TEMP=$(mktemp)
echo "${{ secrets.DEPLOY_KEY }}" > $TEMP
ssh -o StrictHostKeyChecking=no -i $TEMP -p ${{ secrets.DEPLOY_PORT }} ${{ secrets.DEPLOY_USERNAME }}@${{ secrets.DEPLOY_HOST }} /mnt/data/blog/update
- name: Check
uses: nick-fields/retry@v2
with:
timeout_seconds: 30
max_attempts: 5
retry_wait_seconds: 2
warning_on_retry: false
command: curl -sSL --fail -m 10 https://gabnotes.org > /dev/null