Skip to content
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

fix: correctly detect PR number when run with workflow_run #294

Merged

Conversation

tbouffard
Copy link
Contributor

@tbouffard tbouffard commented Apr 19, 2024

Update the call to the GitHub Rest API, as the previous one wasn't able to retrieve the Pull Request associated to the workflow_run.

From time to time, the API call may get rate limit errors given search API seems to use many calls internally. In this case, the error is caught and a warning is logged. Running the workflow again should then succeed.

Using workflow_run lets do surge deployment when the PR is created from a fork.

This makes this action directly usable instead of developing custom solutions like in 
ant-design/ant-design-pro@v6.0.0-beta.1/.github/workflows/preview-deploy.yml which recreate the whole action logic in the workflow definition.

Fixes #124
This fix was developed in collaboration with @benjaminParisel

Notes

This change has been intensively tested through a custom implementation of the surge-preview action provided in benjaminParisel#1 (same content as the PR proposed here).
This custom implementation has been tested in a PR created from a fork repo, see process-analytics/github-actions-playground#349. It has also been tested with PR created from the target repository, see process-analytics/github-actions-playground#350.

The implementation is adapted from https://github.com/orgs/community/discussions/25220#discussioncomment-8697399. The API rate limit was mentioned in https://github.com/orgs/community/discussions/25220#discussioncomment-8971083 and we have encountered once or twice during our tests. That's why we decided to handle the error and add a warning log in this case.

The dist folder has not been updated to include binary changes, and let the maintainers of this repo do the update by themself. If you need me to push the dist folder as well, please let me know.

If this PR is merged, we could later contribute to documentation improvements to describe the workflow_run usage to manage deployment for PR created from a fork repository. For example, explain:

Update the call to the GitHub Rest API, as the previous one wasn't able to retrieve the Pull Request
associated to the workflow_run.

From time to time, the API call may get rate limit errors given search API seems to use many calls
internally. In this case, the error is caught and a warning is logged.
Running the workflow again should then succeed.

Co-authored-by: benjaminparisel <benjamin.parisel@bonitasoft.com>
Co-authored-by: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com>
@afc163
Copy link
Owner

afc163 commented Apr 20, 2024

@tbouffard Gread job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't use surge-preview for pull-request
2 participants