patreon callouts #12
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: Test, build and deploy | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.12 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run tests | |
run: | | |
python -m unittest discover | |
build: | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.event_name == 'push' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Log in to the Github Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push container | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/${{ github.repository }}:latest | |
platforms: linux/amd64,linux/arm64 | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.event_name == 'push' | |
steps: | |
- name: Setup Tailscale | |
id: tailscale | |
uses: tailscale/github-action@main | |
with: | |
authkey: ${{ secrets.TS_AUTHKEY }} | |
version: 1.58.2 | |
- name: Pull and restart latest container | |
run: | | |
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "ubuntu@ktcorp" "cd /home/ubuntu/rss-lambda && docker compose pull && docker compose up -d" | |
notify: | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
- build | |
- deploy | |
if: github.event_name == 'push' | |
steps: | |
- name: Send a Discord notification | |
uses: nobrayner/discord-webhook@v1 | |
with: | |
github-token: ${{ secrets.github_token }} | |
discord-webhook: ${{ secrets.DISCORD_WEBHOOK }} |