From 2aa20ca388633cc846c40ae208e63c6c2a27168d Mon Sep 17 00:00:00 2001 From: Sindre Kjelsrud Date: Sun, 17 Mar 2024 11:24:06 +0100 Subject: [PATCH] :construction_worker: update CI build to use server instead of GitHub Pages Signed-off-by: Sindre Kjelsrud --- .github/workflows/deploy.yml | 51 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3e11f34..8090234 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,8 +1,6 @@ -name: Deploy to GitHub Pages +name: Deploy website on: - # Trigger the workflow every time you push to the `main` branch - # Using a different branch name? Replace `main` with your branch’s name push: branches: [ main ] paths-ignore: @@ -10,32 +8,31 @@ on: # Allows you to run this workflow manually from the Actions tab on GitHub. workflow_dispatch: -# Allow this job to clone the repo and create a page deployment -permissions: - contents: read - pages: write - id-token: write - jobs: - build: + build-and-deploy: runs-on: ubuntu-latest steps: - - name: Checkout your repository using git + - name: Checkout repository uses: actions/checkout@v3 - - name: Install, build, and upload your site - uses: withastro/action@v1 - # with: - # path: . # The root location of your Astro project inside the repository. (optional) - # node-version: 18 # The specific version of Node that should be used to build your site. Defaults to 18. (optional) - # package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional) - deploy: - needs: build - runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 \ No newline at end of file + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '21' + cache: 'yarn' + + - name: Install dependencies + run: yarn install + + - name: Build Astro website + run: yarn build + + - name: Deploy and Reload Caddy + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER }} + key: ${{ secrets.KEY }} + script: | + rsync -avzr --delete $GITHUB_WORKSPACE/dist/ ${{ secrets.USER }}@${{ secrets.HOST }}:/var/www/kjelsrud.dev/ + sudo systemctl reload caddy