name: DuneRealms Web CI on: push: branches: - main paths: - 'website/**' - '.forgejo/workflows/web-deploy.yml' workflow_dispatch: jobs: web: runs-on: dune-ci steps: - name: Checkout shell: bash env: REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git init . git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/MC.git "$GITHUB_SHA" git checkout --detach FETCH_HEAD - name: Install Node 22 uses: actions/setup-node@v4 with: node-version: '22' - name: Prepare publication comparison shell: bash env: REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | BEFORE=$(node -e 'const fs=require("fs");const p=process.env.GITHUB_EVENT_PATH;const e=p&&fs.existsSync(p)?JSON.parse(fs.readFileSync(p)):{};process.stdout.write(e.before||"");') if [[ ! "$BEFORE" =~ ^[0-9a-f]{40}$ || "$BEFORE" =~ ^0+$ ]]; then git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --deepen=1 https://www.dunerealms.com/git/unimatrix/MC.git "$GITHUB_SHA" BEFORE=$(git rev-parse HEAD^) else git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/MC.git "$BEFORE" fi node website/scripts/publication-changes.mjs "$BEFORE" "$GITHUB_SHA" - name: Verify deployment policy run: | node --test .forgejo/tests/web-deploy.test.mjs python3 -m unittest discover -s website/ops -p 'test_*.py' - name: Build and test website working-directory: website run: | corepack enable corepack pnpm install --frozen-lockfile corepack pnpm build corepack pnpm test node --test --test-concurrency=1 ../tools/tests/*.test.mjs - name: Upload website build if: github.ref == 'refs/heads/main' uses: actions/upload-artifact@v3 with: name: DuneRealms-Website path: website/dist/ if-no-files-found: error retention-days: 1 - name: Trigger deployment after successful CI if: github.ref == 'refs/heads/main' shell: bash env: DEPLOY_KEY: ${{ secrets.DUNEREALMS_DEPLOY_KEY }} run: | install -m 700 -d ~/.ssh printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key trap 'rm -f ~/.ssh/deploy_key' EXIT printf '%s\n' '91.107.196.242 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC8x/XocsIz41fWHGty0DbZhSvafSQFt9jaHHgzdr55W root@ubuntu-4gb-fsn1-1' >> ~/.ssh/known_hosts ssh -p 22 -i ~/.ssh/deploy_key -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes dunedeploy@91.107.196.242 "$GITHUB_SHA" rm -f ~/.ssh/deploy_key