2023-11-23 09:36:10 +00:00
|
|
|
name: Build and Deploy
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- "master"
|
|
|
|
paths-ignore:
|
|
|
|
- ".sqlx"
|
|
|
|
- "**.md"
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build-docker:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- name: Cache Docker layers
|
2023-12-17 21:03:45 +00:00
|
|
|
uses: https://github.com/actions/cache/restore@v3
|
2023-11-23 09:36:10 +00:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
/tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-admin_worker-${{ gitea.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-admin_worker-
|
|
|
|
|
|
|
|
- name: Login to Container Registry
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: git.nerdcult.net/nerdcult
|
|
|
|
username: nerdcultbot
|
|
|
|
password: ${{ secrets.NerdcultBotToken }}
|
|
|
|
|
|
|
|
- name: Build and Push
|
|
|
|
uses: docker/build-push-action@v5
|
|
|
|
env:
|
|
|
|
ACTIONS_RUNTIME_TOKEN: ''
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: true
|
|
|
|
tags: git.nerdcult.net/nerdcult/nerdcult_admin_worker:latest
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
2023-12-17 21:03:45 +00:00
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
2023-11-23 09:36:10 +00:00
|
|
|
|
|
|
|
- name: Rotate the cache
|
|
|
|
run: |
|
2023-12-17 21:03:45 +00:00
|
|
|
rm -rvf /tmp/.buildx-cache
|
|
|
|
mv -v /tmp/.buildx-cache-new /tmp/.buildx-cache
|
2023-11-23 09:36:10 +00:00
|
|
|
|
|
|
|
- name: Deploy
|
|
|
|
env:
|
|
|
|
TOWER_TOKEN: ${{ secrets.WatchtowerToken}}
|
|
|
|
TOWER_URI: ${{ secrets.WatchtowerURI}}
|
|
|
|
run: |
|
|
|
|
curl -H "Authorization: Bearer $TOWER_TOKEN" $TOWER_URI
|