From ef49792ab78ba3ffd5e87354ee3a0544df32b790 Mon Sep 17 00:00:00 2001 From: Wietse Wind Date: Thu, 3 Jul 2025 11:09:01 +0200 Subject: [PATCH] build & deploy --- .github/workflows/astro.yml | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/astro.yml diff --git a/.github/workflows/astro.yml b/.github/workflows/astro.yml new file mode 100644 index 0000000..17a1804 --- /dev/null +++ b/.github/workflows/astro.yml @@ -0,0 +1,42 @@ +name: Build Astro Project + +on: + push: + branches: [ prod ] + pull_request: + branches: [ prod ] + types: [ closed ] + +jobs: + build: + # Only run on merged PRs or direct pushes to prod + if: github.event_name == 'push' || (github.event.pull_request.merged == true) + + runs-on: [self-hosted, web] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build Astro project + run: npm run build + + - name: Backup and deploy to web server + run: | + # Create backup of current site + TIMESTAMP=$(date +%s) + cp -r /var/www/site /tmp/site_$TIMESTAMP + echo "✅ Current site backed up to /tmp/site_$TIMESTAMP" + + # Deploy new build + cp -r dist/* /var/www/site/ + echo "✅ Build deployed successfully to /var/www/site"