charasheet/.github/workflows/publish.yaml

54 lines
1.5 KiB
YAML
Raw Normal View History

name: Test, build, publish & deploy
2022-10-31 09:02:54 +01:00
on:
2023-01-30 15:09:11 +01:00
workflow_dispatch:
2022-10-31 09:02:54 +01:00
push:
branches:
- master
2023-01-18 15:12:12 +01:00
permissions:
contents: read
2022-10-31 09:02:54 +01:00
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@v4
2022-10-31 09:02:54 +01:00
- name: Log in to Docker Hub
uses: docker/login-action@v3
2022-10-31 09:02:54 +01:00
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
2022-10-31 09:02:54 +01:00
with:
context: .
push: true
tags: crocmagnon/charasheet:latest
cache-from: type=registry,ref=crocmagnon/charasheet:latest
cache-to: type=inline
platforms: linux/amd64
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/charasheet/update
- name: Check
uses: nick-fields/retry@v3
2022-10-31 09:02:54 +01:00
with:
timeout_seconds: 30
max_attempts: 5
retry_wait_seconds: 2
warning_on_retry: false
2022-11-09 21:33:54 +01:00
command: curl -sSL --fail -m 10 https://charasheet.augendre.info | grep ${GITHUB_SHA::7} > /dev/null