portulan/.forgejo/workflows/deploy.yaml
Gu://em_ 28f9168276
All checks were successful
Build and deploy all / build (amiral.json, /var/www/amiral, amiral) (push) Successful in 1m33s
Build and deploy all / build (atlantis.json, /var/www/atlantis, atlantis) (push) Successful in 1m31s
Build and deploy all / build (harbor.json, /var/www/harbor, harbor) (push) Successful in 29s
Build and deploy all / deploy (amiral.json, /var/www/amiral, amiral) (push) Successful in 14s
Build and deploy all / deploy (harbor.json, /var/www/harbor, harbor) (push) Successful in 14s
Build and deploy all / deploy (atlantis.json, /var/www/atlantis, atlantis) (push) Successful in 1m12s
Build and deploy all / notify (push) Successful in 2s
Attempt to use a NodeJS-ready image instead of the previous generic one
2026-04-13 19:45:36 +02:00

121 lines
3.3 KiB
YAML

x-site_matrix: &site_matrix
- site: "harbor"
dest: /var/www/harbor
config_file: "harbor.json"
- site: "atlantis"
dest: /var/www/atlantis
config_file: "atlantis.json"
- site: "amiral"
dest: /var/www/amiral
config_file: "amiral.json"
name: Build and deploy all
on:
push:
branches:
- main
jobs:
build:
runs-on: docker
strategy:
matrix:
include: *site_matrix
container:
image: node:22-bookworm
steps:
- 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: Enable pnpm
run: corepack enable && corepack prepare pnpm@latest --activate
- 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
uses: https://github.com/webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- 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 }} -o StrictHostKeyChecking=no" \
--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 }}"