Skip to content

Commit

Permalink
Merge pull request #550 from bstansberry/Issue_549
Browse files Browse the repository at this point in the history
[Issue_549] Have the update_post workflow merge main into the 'update…
  • Loading branch information
bstansberry authored Feb 29, 2024
2 parents b913635 + 69f02de commit 4746bfe
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/update_post.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Update the blog post's date"
name: "Update a blog post's date (with merge)"

on:
workflow_dispatch:
Expand Down Expand Up @@ -38,6 +38,11 @@ jobs:
echo "Checking out PR${ORIGINAL_PR}"
gh pr checkout "${ORIGINAL_PR}" --repo "${REPO_ID}"
FIX_BRANCH_NAME="fix_pr_${ORIGINAL_PR}"
// Issue_549 Merge main into the PR branch to avoid permission issues if main
// includes .github/workflows changes that are not in the PR branch
MERGE_TARGET="$(git branch --show-current 2>/dev/null)"
git merge main -m "Merge 'main' into '${MERGE_TARGET}'"
SOURCE_LINK="[PR${ORIGINAL_PR}]($(gh browse ${ORIGINAL_PR} --repo "${REPO_ID}" -n))"
else
Expand All @@ -52,6 +57,10 @@ jobs:
exit 1
fi
echo "Creating a new branch: "
git checkout -b "${FIX_BRANCH_NAME}"
readonly OLD_DATE=$(echo ${OLD_POST} | sed -E "s/([0-9]{4}\-[0-9]{2}\-[0-9]{2}).*/\1/")
echo "Replacing ${OLD_DATE} in the blog post"
Expand All @@ -62,8 +71,7 @@ jobs:
git mv _posts/${OLD_POST} _posts/${NEW_POST}
echo "Creating a new branch: "
git checkout -b "${FIX_BRANCH_NAME}"
echo "Committing changes and creating update PR"
git config --global user.name "${COMMIT_USERNAME}"
Expand Down

0 comments on commit 4746bfe

Please sign in to comment.