portulan/.forgejo/workflows/deploy.yaml
Gu://em_ 30d438e0cb
Some checks failed
Build and deploy all / build (test.json, /var/www/crashtest, test) (push) Successful in 42s
Build and deploy all / deploy (test.json, /var/www/crashtest, test) (push) Failing after 10s
Build and deploy all / notify (push) Successful in 1s
CI fix tentative #19
2026-03-30 22:47:47 +02:00

139 lines
3.8 KiB
YAML

x-site_matrix: &site_matrix
- site: "test"
dest: "/var/www/crashtest"
config_file: "test.json"
# - 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"
name: Build and deploy all
on:
push:
branches:
- main
jobs:
build:
runs-on: docker
strategy:
matrix:
include: *site_matrix
steps:
- name: Debug Matrix
run: |
echo "Full Matrix Site: '${{ matrix.site }}'"
echo "Full Matrix Config: '${{ matrix.config_file }}'"
echo "Dump Matrix Context: "
echo '${{ toJSON(matrix) }}'
- name: Checkout git repository
uses: actions/checkout@v4
with:
path: "source"
- name: Retrieve configs
uses: actions/checkout@v4
with:
repository: ${{ secrets.CONFIG_REPO }}
token: ${{ secrets.CONFIG_REPO_TOKEN }}
path: "configs"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies and config
run: |
cp ./configs/${{ matrix.config_file }} ./source/src/data/content.json
cd ./source
pnpm install
- name: Build the project
run: |
cd ./source
pnpm run build
- name: Save the result for deployment
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.site }}
path: "source/dist/"
deploy:
needs: build
runs-on: docker
strategy:
matrix:
include: *site_matrix
steps:
- name: Install Deployment Tools
run: |
if command -v apk >/dev/null; then
apk add --no-cache rsync openssh-client
else
apt-get update && apt-get install -y rsync openssh-client
fi
- 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: Download Artifact
uses: actions/download-artifact@v3
with:
name: build-${{ matrix.site }}
path: ./dist
- 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
run: |
STATUS="${{ needs.deploy.result }}"
COLOR=$([ "$STATUS" == "success" ] && echo "48867" || echo "16711680")
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"embeds": [{
"title": "Deployment Report",
"color": '$COLOR',
"description": "Status: **'$STATUS'**\nRepo: ${{ github.repository }}\nCommit: ${{ github.sha }}"
}]
}' \
"${{ secrets.DISCORD_WEBHOOK_URL }}"
# 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 }}"