From 9a81194fe9ffbd318b6c55c6131c4b19e56c54a3 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sun, 14 Jul 2024 04:36:03 +0100 Subject: [PATCH] Add workflow that generates staging deploys --- .github/workflows/deploy-site.yml | 121 ++++++++++++++++++++++++++++++ .github/workflows/deploy.yaml | 54 ------------- 2 files changed, 121 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/deploy-site.yml delete mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml new file mode 100644 index 0000000..9317917 --- /dev/null +++ b/.github/workflows/deploy-site.yml @@ -0,0 +1,121 @@ +name: Deploy site + +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + build: + name: Build site + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - uses: actions/upload-artifact@v4 + with: + name: site-build + path: dist + if-no-files-found: error + + deploy-production: + name: Deploy to Production + needs: [build] + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + environment: production + + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: site-build + + - name: Tailscale + uses: tailscale/github-action@v2 + with: + oauth-client-id: ${{ secrets.TAILSCALE_OAUTH_CLIENT_ID }} + oauth-secret: ${{ secrets.TAILSCALE_OAUTH_CLIENT_SECRET }} + tags: tag:ci + + - name: Configure SSH + run: | + mkdir -p ~/.ssh/ + echo "$SSH_KEY" > ~/.ssh/production.key + chmod 600 ~/.ssh/production.key + cat >>~/.ssh/config < ~/.ssh/production.key + chmod 600 ~/.ssh/production.key + cat >>~/.ssh/config < ~/.ssh/production.key - chmod 600 ~/.ssh/production.key - cat >>~/.ssh/config <