Build & Deploy Website #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Deploy Website | |
on: | |
push: | |
branches: | |
- main | |
- development | |
paths: | |
- "Source/Website/**" | |
pull_request: | |
branches: | |
- main | |
- development | |
paths: | |
- "Source/Website/**" | |
workflow_dispatch: | |
workflow_call: | |
secrets: | |
DEPLOY_HOST: | |
required: true | |
DEPLOY_USERNAME: | |
required: true | |
DEPLOY_KEY: | |
required: true | |
DEPLOY_FOLDER: | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: Build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Dependencies | |
run: sudo apt-get install -y musl-dev libssl-dev pkg-config libudev-dev | |
- name: Add Nightly Toolchain | |
run: | | |
rustup toolchain install nightly | |
rustup default nightly | |
- name: Build | |
working-directory: ./Source | |
run: | | |
cargo build --package ficsit-networks-repository-website --verbose --release | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Install PNPM packages | |
working-directory: ./Source/Website | |
run: pnpm install | |
- name: Run Tailwind | |
working-directory: ./Source/Website | |
run: pnpm run tailwind | |
- name: Prepare Upload | |
working-directory: ./Source | |
run: | | |
cp target/release/ficsit-networks-repository-website ./Website | |
chmod 770 ./Website/ficsit-networks-repository-website | |
- name: Upload Website | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Website | |
path: | | |
./Source/Website/ficsit-networks-repository-website | |
./Source/Website/static/ | |
deploy: | |
needs: build | |
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' | |
runs-on: ubuntu-latest | |
name: Deploy | |
steps: | |
- name: Download Website | |
uses: actions/download-artifact@v4 | |
with: | |
name: Website | |
path: ./Source/Website | |
- name: Copy Website artifact to server | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEPLOY_HOST }} | |
username: ${{ secrets.DEPLOY_USERNAME }} | |
key: ${{ secrets.DEPLOY_KEY }} | |
source: "./Source/Website/*" | |
target: "FIN-Repo" | |
- name: Copy to LXC | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEPLOY_HOST }} | |
username: ${{ secrets.DEPLOY_USERNAME }} | |
key: ${{ secrets.DEPLOY_KEY }} | |
script: | | |
pct push 101 FIN-Repo/Source/Website /root/FicsIt-Networks-Repository/Website | |
- name: Docker Compose | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEPLOY_HOST }} | |
username: ${{ secrets.DEPLOY_USERNAME }} | |
key: ${{ secrets.DEPLOY_KEY }} | |
script: | | |
cd ${{ secrets.DEPLOY_FOLDER }} | |
chmod 770 ./Website/ficsit-networks-repository-website | |
docker compose up -d --build --force-recreate |