Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions .github/workflows/dependency-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,33 @@ jobs:
# No --reviewer here: .github/CODEOWNERS already requests a review for every file
# this PR touches, and passing a team reviewer explicitly can fail depending on the
# GITHUB_TOKEN's permissions.
gh pr create --base main --head "$BRANCH" \
--title "chore: weekly dependency security refresh" \
--body-file pr-body.md
#
# Actions cannot open a PR when the org/repo policy "Allow GitHub Actions to create
# and approve pull requests" is disabled. By this point the branch is pushed and the
# build is green, so the work is not lost. Failing the run would put a red X on the
# weekly job every week for a reason nobody can fix from the workflow, which just
# trains people to ignore it. Surface an actionable link instead.
if ! gh pr create --base main --head "$BRANCH" \
--title "chore: weekly dependency security refresh" \
--body-file pr-body.md 2> pr-error.log; then
cat pr-error.log >&2
if grep -q "not permitted to create or approve pull requests" pr-error.log; then
echo "::warning::Branch '$BRANCH' was pushed and is green, but Actions is not allowed to open PRs in this repo. Open it manually, or enable Settings > Actions > General > 'Allow GitHub Actions to create and approve pull requests'."
{
echo "## Dependency refresh is ready, but the PR could not be opened automatically"
echo
echo "Branch \`$BRANCH\` has been pushed and the build passed."
echo
echo "**Open the PR:** https://github.com/${GITHUB_REPOSITORY}/compare/main...${BRANCH}?expand=1"
echo
echo "To let future runs open it themselves, enable **Settings > Actions > General >"
echo "\"Allow GitHub Actions to create and approve pull requests\"**."
echo
echo "---"
echo
cat pr-body.md
} >> "$GITHUB_STEP_SUMMARY"
else
exit 1
fi
fi
Loading