cookiecutter-django/{{cookiecutter.project_slug}}/.github/workflows/publish.yaml

54 lines
1.6 KiB
YAML
Raw Normal View History

2023-03-14 19:51:11 +01:00
name: Test, build, publish & deploy
2023-01-27 10:55:43 +01:00
on:
2023-01-30 16:03:48 +01:00
workflow_dispatch:
2023-01-27 10:55:43 +01:00
push:
branches:
- master
permissions:
contents: read
jobs:
tests:
uses: ./.github/workflows/test.yaml
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: [tests]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2{% raw %}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}{% endraw %}
- name: Build and push Docker image
2023-03-14 19:51:11 +01:00
uses: docker/build-push-action@v4
2023-01-27 10:55:43 +01:00
with:
context: .
push: true
tags: crocmagnon/{{cookiecutter.project_slug}}:latest
cache-from: type=registry,ref=crocmagnon/{{cookiecutter.project_slug}}:latest
cache-to: type=inline
platforms: linux/amd64
deploy:
name: Deploy new image
runs-on: ubuntu-latest
needs: [push_to_registry]
steps:
2023-01-27 11:18:42 +01:00
- name: Deploy
2023-01-27 10:55:43 +01:00
run: |
2023-01-27 11:18:42 +01:00
TEMP=$(mktemp){% raw %}
2023-01-27 10:55:43 +01:00
echo "${{ secrets.DEPLOY_KEY }}" > $TEMP
2023-01-27 11:18:42 +01:00
ssh -o StrictHostKeyChecking=no -i $TEMP -p ${{ secrets.DEPLOY_PORT }} ${{ secrets.DEPLOY_USERNAME }}@${{ secrets.DEPLOY_HOST }}{% endraw %} /mnt/data/{{cookiecutter.project_slug}}/update
2023-01-27 10:55:43 +01:00
- 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://{{cookiecutter.project_slug}}.augendre.info | grep ${GITHUB_SHA::7} > /dev/null