diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d926d75..cabf19c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,25 +1,34 @@ name: Deploy on: - workflow_dispatch: # Allows manual trigger - push: - branches: [v1] + workflow_dispatch: pull_request: - branches: [v1] + push: + branches: + - v1 + +permissions: + contents: read jobs: - deploy: - name: Deploy + deploy-preview: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest timeout-minutes: 15 + environment: + name: Preview + url: ${{ steps.netlify.outputs.unique-url }} + permissions: - id-token: write # Needed for auth with Deno Deploy - contents: read # Needed to clone the repository + contents: read + pull-requests: write steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 + with: + fetch-depth: 0 - name: Setup Deno uses: denoland/setup-deno@v2 @@ -41,9 +50,94 @@ jobs: - name: Staticalize run: deno task staticalize - - name: Upload to Deno Deploy - uses: denoland/deployctl@v1 + - name: Deploy Preview to Netlify + id: netlify + run: | + PR_NUMBER="${{ github.event.pull_request.number }}" + COMMIT_SHA="${{ github.event.pull_request.head.sha }}" + + DEPLOY_OUTPUT=$(npx netlify-cli deploy \ + --dir=built \ + --alias="pr-$PR_NUMBER" \ + --message="Preview for PR #$PR_NUMBER at commit $COMMIT_SHA" \ + --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} \ + --site=${{ secrets.NETLIFY_SITE_ID }} \ + --json) + + DEPLOY_ID=$(echo "$DEPLOY_OUTPUT" | jq -r '.deploy_id') + SITE_NAME=$(echo "$DEPLOY_OUTPUT" | jq -r '.site_name') + + UNIQUE_URL="https://${DEPLOY_ID}--${SITE_NAME}.netlify.app" + STABLE_URL="https://pr-${PR_NUMBER}--${SITE_NAME}.netlify.app" + + echo "unique-url=$UNIQUE_URL" >> $GITHUB_OUTPUT + echo "stable-url=$STABLE_URL" >> $GITHUB_OUTPUT + + - name: Comment PR with Preview Link + uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5 + with: + header: netlify-preview-deploy + message: | + 🚀 **Deploy Preview Ready!** + + * **Stable Review Link:** ${{ steps.netlify.outputs.stable-url }} + * **Latest Commit Snapshot:** ${{ steps.netlify.outputs.unique-url }} + + deploy-production: + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + timeout-minutes: 15 + environment: + name: Production + url: https://graphgen-data.netlify.app + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Setup Deno + uses: denoland/setup-deno@v2 with: - project: graphgen - entrypoint: "jsr:@std/http/file-server" - root: built + deno-version: v2.x + + - name: Start Fresh server + run: | + deno run -A main.ts & + until curl --output /dev/null --silent --head --fail http://127.0.0.1:8000; do + printf '.' + sleep 1 + done + env: + PORT: 8000 + timeout-minutes: 5 + working-directory: ./www + + - name: Staticalize + run: deno task staticalize + + - name: Deploy to Production + run: | + npx netlify-cli deploy \ + --dir=built \ + --prod \ + --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} \ + --site=${{ secrets.NETLIFY_SITE_ID }} + + trigger-frontside-rebuild: + needs: deploy-production + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Wait for Netlify propagation + run: sleep 60 + + - name: Trigger frontside.com production rebuild + env: + GH_TOKEN: ${{ secrets.FRONTSIDEJACK_GITHUB_TOKEN }} + run: | + gh workflow run deploy.yaml \ + --repo thefrontside/frontside.com \ + --ref production diff --git a/deno.json b/deno.json index e601c2a..72cec9f 100644 --- a/deno.json +++ b/deno.json @@ -13,7 +13,7 @@ "build:cli": "cd cli && deno task build:cli", "dev": "cd www && deno run -A dev.ts", "start": "cd www && deno run -A main.ts", - "staticalize": "deno run -A jsr:@frontside/staticalize@0.2.2/cli --site http://localhost:8000 --output=built --base=https://graphgen.deno.dev && deno run -A fix-static-css.ts" + "staticalize": "deno run -A jsr:@frontside/staticalize@0.2.6/cli --site http://localhost:8000 --output=built --base=https://graphgen-data.netlify.app && deno run -A fix-static-css.ts" }, "lint": { "rules": { diff --git a/www/deno.lock b/www/deno.lock index a2b168f..2231ede 100644 --- a/www/deno.lock +++ b/www/deno.lock @@ -368,15 +368,15 @@ "https://esm.sh/prismjs@1.27.0": "7f6ded0fc99551dc2132703ab0beb6670dd99a8a09027015db80d9500e644cb3", "https://esm.sh/prismjs@1.27.0/components/prism-diff.js?no-check": "39fc9d5a6c46626869561e143a51013e5f45420cd909833f9372617ef082cea3", "https://esm.sh/prismjs@1.27.0/components/prism-graphql?no-check": "334cf159686add06d610bef49f1abc1bf56cf2aae3f56abd83e928d8134f2d07", - "https://esm.sh/prismjs@1.27.0/components/prism-jsx.js?no-check": "0f4a61f2a4a8434ef36a226ef42a717479218a23b899b29fd5166f6c7a7ff40a", - "https://esm.sh/prismjs@1.27.0/components/prism-tsx.js?no-check": "98dace917708ad66f65a5386f5e23273b740a5b44e6bfbf75454030bdd5f4492", + "https://esm.sh/prismjs@1.27.0/components/prism-jsx.js?no-check": "0dfd4ffac157ebc92bb579cbab043d6ccb551bd69a754e83640518149a649a01", + "https://esm.sh/prismjs@1.27.0/components/prism-tsx.js?no-check": "898b6bc85654cb48e97438004bf0316887b43f4388212876708c58172e8d53f1", "https://esm.sh/prismjs@1.27.0/components/prism-typescript.js?no-check": "cb2e013db75118b2de3eb4fa653ad13b7a8ff29ac06923bcf7cdb9e713c8d16b", + "https://esm.sh/prismjs@1.27.0/deno/components/prism-jsx.mjs": "7a838ae3cf11dc44a23a51eb9d1db8ea8bfe24a22d9e8cf0bc0e2d793305aa23", "https://esm.sh/prismjs@1.27.0/denonext/components/prism-diff.mjs": "a666c1fa1a1b434ba6232e3e6a5148d986986a8e621d5a0b6d7ea845fc8bdfd5", "https://esm.sh/prismjs@1.27.0/denonext/components/prism-graphql.mjs": "9bbe24abdf8c43b66a57c4c99a5457fb806bd82c3d0b260a9d1f9965ad3c925e", - "https://esm.sh/prismjs@1.27.0/denonext/components/prism-jsx.mjs": "7a838ae3cf11dc44a23a51eb9d1db8ea8bfe24a22d9e8cf0bc0e2d793305aa23", - "https://esm.sh/prismjs@1.27.0/denonext/components/prism-tsx.mjs": "7450c51f1d9cb09b96642d2ff46e4318c020a9ee4a9378591cc44c0456752669", "https://esm.sh/prismjs@1.27.0/denonext/components/prism-typescript.mjs": "ccdf82242290db64b498a3de52da7f4f04653507608aeea2d6a5a31c2ebaa88f", "https://esm.sh/prismjs@1.27.0/denonext/prismjs.mjs": "37412853d75d55f17215eced994ece328ffa7b72e6897809a1ad5a95e092c28c", + "https://esm.sh/prismjs@1.27.0/es2022/components/prism-tsx.mjs": "7450c51f1d9cb09b96642d2ff46e4318c020a9ee4a9378591cc44c0456752669", "https://esm.sh/sanitize-html@2.7.0": "3b5b957c3195c7a542d6bda27b7ad3d9d320a8af64cbf7cd63aed8b8d92a0678", "https://esm.sh/sanitize-html@2.7.0/denonext/sanitize-html.mjs": "3e69efbd4fd5cdb8f76097550386d59b2cb222d7dea561a9aab31a321822db01", "https://esm.sh/source-map-js@1.2.1/denonext/source-map-js.mjs": "abc9dc062280bfd334ef791e2b520633293a1eb1a001ae9c9e3078d2638c3305",