2026-03-27 23:33:21 +01:00
|
|
|
name: Build and deploy all
|
2026-03-15 18:38:59 +01:00
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches:
|
|
|
|
|
- main
|
|
|
|
|
|
2026-03-27 23:33:21 +01:00
|
|
|
x-site-config: &site_matrix
|
|
|
|
|
include:
|
2026-03-30 18:27:50 +02:00
|
|
|
- site: "test"
|
|
|
|
|
dest: /var/www/crashtest
|
2026-03-30 19:00:37 +02:00
|
|
|
config_file: "test.json"
|
2026-03-30 19:04:34 +02:00
|
|
|
|
2026-03-30 18:27:50 +02:00
|
|
|
# - site: "harbor"
|
|
|
|
|
# dest: /var/www/harbor
|
|
|
|
|
# secret_key: "CONFIG_HARBOR"
|
2026-03-27 23:33:21 +01:00
|
|
|
# - site: "atlantis"
|
|
|
|
|
# dest: /var/www/atlantis
|
|
|
|
|
# secret_key: "CONFIG_ATLANTIS"
|
|
|
|
|
# - site: "amiral"
|
|
|
|
|
# dest: /var/www/amiral
|
|
|
|
|
# secret_key: "CONFIG_AMIRAL"
|
|
|
|
|
|
2026-03-15 18:38:59 +01:00
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: docker
|
2026-03-27 23:33:21 +01:00
|
|
|
strategy:
|
|
|
|
|
matrix: *site_matrix
|
2026-03-15 18:38:59 +01:00
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
- name: Checkout git repository
|
|
|
|
|
uses: actions/checkout@v4
|
2026-03-30 17:36:47 +02:00
|
|
|
with:
|
|
|
|
|
path: "source"
|
2026-03-15 18:38:59 +01:00
|
|
|
|
2026-03-30 19:00:37 +02:00
|
|
|
- name: Retrieve configs
|
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
with:
|
|
|
|
|
repository: ${{ secrets.CONFIG_REPO }}
|
2026-03-30 19:28:36 +02:00
|
|
|
token: ${{ secrets.CONFIG_REPO_TOKEN }}
|
2026-03-30 19:00:37 +02:00
|
|
|
path: "configs"
|
2026-03-27 23:33:21 +01:00
|
|
|
|
|
|
|
|
- name: Install pnpm
|
2026-03-15 18:38:59 +01:00
|
|
|
uses: pnpm/action-setup@v4
|
|
|
|
|
with:
|
|
|
|
|
version: 10
|
|
|
|
|
|
|
|
|
|
- name: Setup Nodejs
|
|
|
|
|
uses: actions/setup-node@v4
|
2026-03-30 17:50:40 +02:00
|
|
|
with:
|
|
|
|
|
node-version: 22
|
2026-03-15 18:38:59 +01:00
|
|
|
|
2026-03-30 19:00:37 +02:00
|
|
|
- name: Install dependencies and config
|
|
|
|
|
run: |
|
|
|
|
|
cp ./configs/${{ matrix.config_file }} ./source/src/data/content.json
|
|
|
|
|
cd ./source
|
|
|
|
|
pnpm install
|
2026-03-15 18:38:59 +01:00
|
|
|
|
2026-03-27 23:33:21 +01:00
|
|
|
- name: Build the project
|
2026-03-15 18:38:59 +01:00
|
|
|
run: pnpm run build
|
|
|
|
|
|
2026-03-27 23:33:21 +01:00
|
|
|
- name: Save the result for deployment
|
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
|
with:
|
|
|
|
|
name: build-${{ matrix.site }}
|
|
|
|
|
path: dist/
|
|
|
|
|
|
2026-03-15 18:38:59 +01:00
|
|
|
deploy:
|
|
|
|
|
needs: build
|
|
|
|
|
runs-on: docker
|
2026-03-27 23:33:21 +01:00
|
|
|
strategy:
|
|
|
|
|
matrix: *site_matrix
|
2026-03-15 18:38:59 +01:00
|
|
|
steps:
|
|
|
|
|
- name: Setup SSH
|
2026-03-27 23:33:21 +01:00
|
|
|
env:
|
|
|
|
|
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
2026-03-15 18:38:59 +01:00
|
|
|
run: |
|
|
|
|
|
mkdir -p ~/.ssh
|
2026-03-27 23:33:21 +01:00
|
|
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
|
|
|
|
chmod 600 ~/.ssh/id_rsa
|
|
|
|
|
ssh-keyscan -p ${{ secrets.SERVER_PORT }} -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts
|
2026-03-15 18:38:59 +01:00
|
|
|
- name: Push
|
|
|
|
|
run: |
|
2026-03-27 23:33:21 +01:00
|
|
|
rsync -avz -e "ssh -p ${{ secrets.SERVER_PORT }}" --delete ./dist/ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:${{ matrix.dest }}
|
|
|
|
|
|
|
|
|
|
notify:
|
|
|
|
|
needs: deploy
|
|
|
|
|
runs-on: docker
|
|
|
|
|
if: always() # Always run
|
|
|
|
|
steps:
|
|
|
|
|
- name: Send Discord Notification
|
2026-03-30 17:36:47 +02:00
|
|
|
uses: https://github.com/appleboy/discord-action@master
|
2026-03-27 23:33:21 +01:00
|
|
|
with:
|
|
|
|
|
color: ${{ needs.deploy.result == 'success' && '48867' || '16711680' }}
|
|
|
|
|
message: |
|
|
|
|
|
**Deployment Report**
|
|
|
|
|
**Status:** ${{ needs.deploy.result }}
|
2026-03-30 17:29:18 +02:00
|
|
|
**Repo:** ${{ github.repository }}
|
|
|
|
|
**Commit:** ${{ github.sha }}
|
|
|
|
|
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
|
|
|
|
|
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
|
2026-03-27 23:33:21 +01:00
|
|
|
|
|
|
|
|
# For later
|
|
|
|
|
# - name: Send Matrix Notification
|
|
|
|
|
# uses: s707/matrix-action@master
|
|
|
|
|
# with:
|
|
|
|
|
# server_url: https://matrix.org
|
|
|
|
|
# room_id: ${{ secrets.MATRIX_ROOM_ID }}
|
|
|
|
|
# access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
|
|
|
|
|
# message: "Deployment of ${{ gitea.repository }} finished with status: ${{ needs.deploy.result }}"
|