portulan/.forgejo/workflows/deploy.yaml

107 lines
2.9 KiB
YAML
Raw Normal View History

name: Build and deploy all
on:
push:
branches:
- main
x-site-config: &site_matrix
include:
- site: "harbor"
dest: /var/www/harbor
secret_key: "CONFIG_HARBOR"
# - site: "atlantis"
# dest: /var/www/atlantis
# secret_key: "CONFIG_ATLANTIS"
# - site: "amiral"
# dest: /var/www/amiral
# secret_key: "CONFIG_AMIRAL"
jobs:
build:
runs-on: docker
strategy:
matrix: *site_matrix
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- name: Inject configs
env:
CONF: ${{ secrets[matrix.secret_key] }}
run: |
echo "$CONF" > src/data/content.json
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
cache: "pnpm"
2026-03-30 17:29:18 +02:00
cache-dependency-path: ./source/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install
- name: Lint code
run: pnpm run lint
- name: Checking code format
run: pnpm run format:check
- name: Build the project
run: pnpm run build
- name: Save the result for deployment
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.site }}
path: dist/
deploy:
needs: build
runs-on: docker
strategy:
matrix: *site_matrix
steps:
- name: Setup SSH
env:
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
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
- name: Push
run: |
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
uses: appleboy/discord-action@master
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 }}
# 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 }}"