-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GHA workflows to auto-merge dependency updates and bundle GB dependency updates per GB plugin release #6302
Add GHA workflows to auto-merge dependency updates and bundle GB dependency updates per GB plugin release #6302
Conversation
if: > | ||
# Auto merge `@wordpress/` dependency PRs | ||
startsWith( ${{ github.event.pull_request.title }}, 'Bump @wordpress' ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can update this if condition as a means to whitelist auto-merging for other dependency updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment this won't do anything because the @wordpress
dependencies are excluded, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, they're ignored in the Dependabot config.
Plugin builds for aadb449 are ready 🛎️!
|
…n update is released
In 4e54f17 I added a new GHA workflow that monitors the Gutenberg repo for plugin releases, and if there is one it opens a PR containing the related dependency updates since that release. |
echo "::set-output name=version::$(echo "$LAST_VERSION")" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
QUERY: 'repo:ampproject/amp-wp is:pr is:open is:merged in:title Update Gutenberg packages after' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this do an author
check as well to be safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 46b6ef7.
id: last-release | ||
run: | | ||
PR_TITLE=$(gh api -X GET search/issues -f q='${{ env.QUERY }}' -f sort='created' -f order='desc' --jq '.items.[].title' | head -n 1) | ||
LAST_VERSION=$(node -e "'$PR_TITLE' && console.log( '$PR_TITLE'.match('v(.+) release')[1] )") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the '$PR_TITLE' &&
part for?
If the matched pull request contains any quotation marks (perhaps by malicious user), then this will cause an error.
Perhaps something like this would be better:
LAST_VERSION=$(node -e "'$PR_TITLE' && console.log( '$PR_TITLE'.match('v(.+) release')[1] )") | |
LAST_VERSION=$(sed 's/.* \(v.*\).*/$1/' <<< "$PR_TITLE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could then also do a check to see if it the resulting LAST_VERSION
matches ^v\d+(\.\d+)*$
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in f0a0dab.
|
||
- name: Determine if with package updates are needed | ||
id: release-status | ||
run: echo "::set-output name=outdated::$(php -r "echo json_encode(version_compare('$LATEST_VER', '$LAST_VER', '>'));")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run: echo "::set-output name=outdated::$(php -r "echo json_encode(version_compare('$LATEST_VER', '$LAST_VER', '>'));")" | |
run: echo "::set-output name=outdated::$(php -r "echo json_encode(version_compare($argv[1], $argv[2], '>'));" "$LATEST_VER" "$LAST_VER" )" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close! I had to instead wrap the command in single quotes to get it working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 52f3426.
Co-authored-by: Weston Ruter <[email protected]>
Co-authored-by: Weston Ruter <[email protected]>
Co-authored-by: Weston Ruter <[email protected]>
fcb0065
to
f0a0dab
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6302 +/- ##
==========================================
Coverage 75.39% 75.40%
Complexity 5881 5881
==========================================
Files 235 235
Lines 17787 17781 -6
==========================================
- Hits 13411 13407 -4
+ Misses 4376 4374 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -25,18 +25,18 @@ jobs: | |||
id: last-release | |||
run: | | |||
PR_TITLE=$(gh api -X GET search/issues -f q='${{ env.QUERY }}' -f sort='created' -f order='desc' --jq '.items.[].title' | head -n 1) | |||
LAST_VERSION=$(node -e "'$PR_TITLE' && console.log( '$PR_TITLE'.match('v(.+) release')[1] )") | |||
LAST_VERSION=$(sed -r 's/.+ v(.+) .+/\1/' <<< "$PR_TITLE") | |||
echo "::set-output name=version::$(echo "$LAST_VERSION")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to ensure only valid version numbers are used, this could could be checked as follows:
echo "::set-output name=version::$(echo "$LAST_VERSION")" | |
if egrep -q '^[0-9][0-9]*(\.[0-9][0-9]*)*$' <<< "$LAST_VERSION"; then | |
echo "::set-output name=version::$(echo "$LAST_VERSION")" | |
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe exit 1
if else
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not a non-zero exit, as that would mark the job as a failure which is techincally not true... unless that's what we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least the job should be skipped entirely?
Er, but at the moment there are no such merged PRs in the repo: https://github.com/ampproject/amp-wp/pulls?q=is%3Apr+author%3Aapp%2Fgithub-actions+is%3Aopen+is%3Amerged+in%3Atitle+Update+Gutenberg+packages+after
I guess in that case LAST_VER
will be empty? So then maybe it should be set to 0.0.0
:
echo "::set-output name=version::$(echo "$LAST_VERSION")" | |
if ! egrep -q '^[0-9][0-9]*(\.[0-9][0-9]*)*$' <<< "$LAST_VERSION"; then | |
LAST_VERSION='0.0.0' | |
fi | |
echo "::set-output name=version::$(echo "$LAST_VERSION")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works 👍.
if: > | ||
# Auto merge `@wordpress/` dependency PRs | ||
startsWith( ${{ github.event.pull_request.title }}, 'Bump @wordpress' ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment this won't do anything because the @wordpress
dependencies are excluded, right?
if: steps.packages.outputs.list != 0 && steps.remote-branch.outputs.exists == 0 | ||
run: | | ||
git push -u origin "$HEAD_BRANCH" | ||
gh pr create --base "$BASE_BRANCH" --title "Update Gutenberg packages after v$VERSION release" --body "" --label dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also do gh pr merge --auto --merge
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea that works here as well, will make the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
Fixes #6298
Adds GHA workflows to:
Checklist