Skip to content

Commit

Permalink
Merge pull request #198 from zetxek/update/preview-prs
Browse files Browse the repository at this point in the history
chore: Update demo PR workflow to improve PR creation and tracking
  • Loading branch information
zetxek authored Feb 6, 2025
2 parents ae268c3 + bf7c264 commit b300db7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/update-demo-pr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Updates demo site (https://github.com/zetxek/adritian-demo)
## taken from https://stackoverflow.com/a/68213855/570087

name: PR demo site (on PR)
name: Preview demo site
## This will open a PR which will open a vercel preview URL in the demo site

on:
Expand Down Expand Up @@ -44,6 +44,7 @@ jobs:
echo "Latest tag: $LATEST_TAG"
echo "Latest commit: $LATEST_COMMIT"
echo "PR URL: $PR_URL"
echo "PR Number: $PR_NUMBER"
git config --global --add --bool push.autoSetupRemote true
Expand Down Expand Up @@ -74,7 +75,7 @@ jobs:
# Commit changes
git add go.mod go.sum
COMMIT_MSG="preview: update theme module to commit \`$LATEST_COMMIT\`"
COMMIT_MSG="preview: theme PR #$PR_NUMBER"
git commit -m "$COMMIT_MSG" && git push --force || echo "No changes to commit"
# Push branch
Expand All @@ -92,12 +93,16 @@ jobs:
echo "PR Exists. Updating pull-request..."
gh pr view
echo "✅ Pull-request updated!"
# TODO: update the PR body with the latest commit
# Add a comment to the PR with the update
gh pr comment $PR_EXISTS --body "Updated PR to last commit in source repo: \`$LATEST_COMMIT\`"
else
echo "✨ Creating new pull-request..."
PR_TITLE="preview: update theme to commit \`$LATEST_COMMIT\`"
PR_BODY="⚠️ The source PR is not merged yet - this is a preview PR.
🤖 This automated PR updates the theme module to a PR in the source repo: $PR_URL.
🔗 Triggered by https://github.com/zetxek/adritian-free-hugo-theme/actions/workflows/update-demo-pr.yml"
PR_TITLE="preview: theme PR #$PR_NUMBER"
PR_BODY="⚠️ The source PR is not merged yet - this is a preview PR created to test the theme update with a vercel preview URL.
- Last commit: \`$LATEST_COMMIT\`
- Source PR: $PR_URL
- 🔗 Triggered by https://github.com/zetxek/adritian-free-hugo-theme/actions/workflows/update-demo-pr.yml"
PR_RESULT=$(gh pr create \
--title "$PR_TITLE" \
Expand Down

0 comments on commit b300db7

Please sign in to comment.