Add Comprehensive Developer Guides and Best Practices #93
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Preview (Internal PRs) | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy Docusaurus Preview | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.head.repo.full_name == github.repository | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
- name: Build website | |
run: npm run build | |
- name: Prepare deployment | |
run: | | |
mkdir -p ./deploy | |
cp -r build/* ./deploy/ | |
cd ./deploy | |
echo '{"name":"deploy","version":"1.0.0","private":true}' > package.json | |
npm install wrangler@3 --save-dev | |
- name: Deploy to Cloudflare Pages | |
working-directory: ./deploy | |
run: | | |
echo "🚀 Starting Cloudflare Pages preview deployment..." | |
PR_NUMBER="${{ github.event.pull_request.number }}" | |
SHORT_SHA="${{ github.event.pull_request.head.sha }}" | |
BRANCH_NAME="pr-${PR_NUMBER}-${SHORT_SHA}" | |
echo "🔗 Deploying branch: ${BRANCH_NAME}" | |
npx wrangler pages deploy . --project-name=docs-docusaurus --commit-dirty=true --branch="${BRANCH_NAME}" 2>&1 | tee deploy.log | |
DEPLOY_URL=$(grep -o 'https://.*\.pages\.dev' deploy.log | head -n 1) | |
if [ -n "$DEPLOY_URL" ]; then | |
echo "DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_ENV | |
else | |
echo "❌ Failed to extract deploy URL." | |
exit 1 | |
fi | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
- name: Comment on PR with Preview URL | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: "🚀 **Preview deployed!**\n🔗 [View preview](${{ env.DEPLOY_URL }})" | |
comment_tag: preview-url |