From 02a267bfd60efb8f69a414d105a513b368cad0df Mon Sep 17 00:00:00 2001 From: Aria Date: Sun, 11 May 2025 21:01:53 +1000 Subject: [PATCH] Auto deploy from git.aria.coffee --- .forgejo/workflows/deploy.yaml | 56 ++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 57 insertions(+) create mode 100644 .forgejo/workflows/deploy.yaml diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml new file mode 100644 index 0000000..9847768 --- /dev/null +++ b/.forgejo/workflows/deploy.yaml @@ -0,0 +1,56 @@ +name: Deploy to Web Server + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install SSH key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.SSH_KEY }} + name: aria-coffee-deploy # optional + known_hosts: ${{ secrets.KNOWN_HOSTS }} + if_key_exists: fail + + - name: Install pnpm + uses: pnpm/action-setup@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 23 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Build website + run: pnpm run build-action + + - name: Create folder if not exists + run: | + ssh -i ~/.ssh/aria-coffee-deploy ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "mkdir -p /var/www/Aria/" + + - name: Clear old backup + run: | + ssh -i ~/.ssh/aria-coffee-deploy ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "[ -d "/var/www/Aria/dist-old" ] && rm -r /var/www/Aria/dist-old" + + - name: Backup current install + run: | + ssh -i ~/.ssh/aria-coffee-deploy ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "[ -d "/var/www/Aria/dist" ] && mv /var/www/Aria/dist /var/www/Aria/dist-old" + + - name: Copy over new build-action + run: | + scp -i ~/.ssh/aria-coffee-deploy -rv ./dist ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }}:/var/www/Aria + + - name: Set permissions on the deployed files + run: | + ssh -i ~/.ssh/aria-coffee-deploy ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} "chmod -R 755 /var/www/Aria/dist" \ No newline at end of file diff --git a/package.json b/package.json index 9f750cc..20ee62e 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "astro dev", "build": "astro check && astro build && ./compress-images.sh", + "build-action": "astro check && astro build", "preview": "astro preview", "astro": "astro" },