From 957c871472cf7e9ca0f2b8c0cc3fe403db409088 Mon Sep 17 00:00:00 2001 From: 0tuedon <90271995+0tuedon@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:10:16 +0100 Subject: [PATCH 1/2] Dynamic preview (#1) * workflow: adds a create preview link yml * feat: test the deployment on fork * fix: deployment bug --- .github/workflows/create-preview-link.yml | 144 ++++++++++++++++++ .../2019-08-22-socratic-seminar-2.md | 2 +- 2 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/create-preview-link.yml diff --git a/.github/workflows/create-preview-link.yml b/.github/workflows/create-preview-link.yml new file mode 100644 index 000000000..34c08fdec --- /dev/null +++ b/.github/workflows/create-preview-link.yml @@ -0,0 +1,144 @@ +name: Build Preview on Command +permissions: + contents: read + pull-requests: write +on: + issue_comment: + types: [created] + +jobs: + build-preview: + runs-on: ubuntu-latest + # Only run on PR comments with the right command from maintainers + if: | + github.event.issue.pull_request && + contains(github.event.comment.body, '/build-preview') && + github.event.comment.author_association == 'OWNER' || + github.event.comment.author_association == 'MEMBER' || + github.event.comment.author_association == 'COLLABORATOR' + + steps: + - name: Get PR details + id: pr + uses: actions/github-script@v7 + with: + result-encoding: string + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number + }); + return JSON.stringify({ + head_sha: pr.data.head.sha, + head_ref: pr.data.head.ref, + head_repo: pr.data.head.repo.clone_url + }); + + - name: Setup Checkout for Bitcoin Transcripts + uses: actions/checkout@v4 + with: + repository: ${{ fromJson(steps.pr.outputs.result).head_repo }} + ref: ${{ fromJson(steps.pr.outputs.result).head_sha }} + path: transcripts + + - name: Setup Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Clone Registry Repo + run: git clone https://github.com/bitcointranscripts/registry.git + + - name: Replace the public/bitcoin-transcript submodule in Registry with contents of this current branch + working-directory: transcripts + run: | + rm -rf ../registry/public/bitcoin-transcript + mkdir -p ../registry/public/bitcoin-transcript + cp -r * ../registry/public/bitcoin-transcript/ + + - name: Install dependencies + working-directory: registry + run: | + npm install + + - name: Run Next.js build only + working-directory: registry + env: + API_KEY: ${{ secrets.API_KEY }} + CLOUD_ID: ${{ secrets.CLOUD_ID }} + INDEX: ${{ secrets.INDEX }} + + run: | + npm run fetch-topics + npm run fetch-reviewers + npx next build + + - name: Install Vercel CLI + run: npm install -g vercel + + - name: Add vercel.json with custom build-only command + working-directory: registry + run: | + cat < vercel.json + { + "buildCommand": "npm run fetch-topics && npm run fetch-reviewers && npx next build" + } + EOF + + - name: Pull Vercel project settings + working-directory: registry + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + run: vercel pull --yes --token=$VERCEL_TOKEN + + - name: Build with Vercel CLI + working-directory: registry + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + API_KEY: ${{ secrets.API_KEY }} + CLOUD_ID: ${{ secrets.CLOUD_ID }} + INDEX: ${{ secrets.INDEX }} + run: vercel build --token=$VERCEL_TOKEN + + - name: Deploy to Vercel + working-directory: registry + env: + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + run: | + vercel deploy --prebuilt --token=$VERCEL_TOKEN --archive=tgz --yes > ../vercel-preview-url.txt + + - name: Store Top-Level Folders + working-directory: transcripts + run: | + git remote add upstream https://github.com/bitcointranscripts/bitcointranscripts.git + git fetch upstream + top_level_folders=$(git diff --name-only upstream/master) + echo $top_level_folders > ../top_level_folders.txt + + - name: Comment PR with Preview URL + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const url = fs.readFileSync('vercel-preview-url.txt', 'utf8').trim(); + const top_level_folders = fs.readFileSync('top_level_folders.txt', 'utf8').trim(); + const dirs = top_level_folders.split(' '); + let commentBody = `Your Transcript Preview is ready:\n`; + if (dirs.length >= 1) { + for (const dir of dirs) { + if(dir.includes(".md")) { + let dir_name = dir.replace(".md", ""); + commentBody += `- [${dir_name}](${url}/${dir_name})\n`; + } + } + commentBody += `- [View All Transcript Sources](${url}/sources)\n`; + } + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: commentBody + }); \ No newline at end of file diff --git a/austin-bitcoin-developers/2019-08-22-socratic-seminar-2.md b/austin-bitcoin-developers/2019-08-22-socratic-seminar-2.md index a3e58f91f..06cf9475f 100644 --- a/austin-bitcoin-developers/2019-08-22-socratic-seminar-2.md +++ b/austin-bitcoin-developers/2019-08-22-socratic-seminar-2.md @@ -10,7 +10,7 @@ tags: ## Introduction -Hello. The idea was to do a more socratic style meetup. This was popularized by Bitdevs NYC and spread to SF. We tried this a few months ago with Jay. The idea is we run through research news, newsletters, podcasters, talk about what happened in the technical bitcoin community. We're going to have different presenters. +Hello. Mike Schmidt is going to talk about some optech newsletters that he has been contributing to. Dhruv will talk about Hermit and Shamir secret sharing. Flaxman will teach us how to setup a multisig hardware wallet with Electrum. He is going to show us how you can actually do this and some of these things we have learned. Bryan Bishop will talk about his vaults proposal that was recently made. So ideally we can keep these each to about 10 minutes. They will probably go over a little though. Let's get a lot of audience participation and really interactive. From fa17ff518b906a05411776f5a5b15455fc30dfc9 Mon Sep 17 00:00:00 2001 From: 0tuedon <90271995+0tuedon@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:23:09 +0100 Subject: [PATCH 2/2] test: preview command --- austin-bitcoin-developers/2019-08-22-socratic-seminar-2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/austin-bitcoin-developers/2019-08-22-socratic-seminar-2.md b/austin-bitcoin-developers/2019-08-22-socratic-seminar-2.md index 06cf9475f..a3e58f91f 100644 --- a/austin-bitcoin-developers/2019-08-22-socratic-seminar-2.md +++ b/austin-bitcoin-developers/2019-08-22-socratic-seminar-2.md @@ -10,7 +10,7 @@ tags: ## Introduction -Hello. +Hello. The idea was to do a more socratic style meetup. This was popularized by Bitdevs NYC and spread to SF. We tried this a few months ago with Jay. The idea is we run through research news, newsletters, podcasters, talk about what happened in the technical bitcoin community. We're going to have different presenters. Mike Schmidt is going to talk about some optech newsletters that he has been contributing to. Dhruv will talk about Hermit and Shamir secret sharing. Flaxman will teach us how to setup a multisig hardware wallet with Electrum. He is going to show us how you can actually do this and some of these things we have learned. Bryan Bishop will talk about his vaults proposal that was recently made. So ideally we can keep these each to about 10 minutes. They will probably go over a little though. Let's get a lot of audience participation and really interactive.