afc163 / surge-preview

🔂 Preview website in surge.sh for every pull request.
149 stars 27 forks source link

Preview comment not being added + CI failing #212

Closed HarshCasper closed 6 months ago

HarshCasper commented 2 years ago

Description

Hi,

Through this PR, I added PR preview for Devfiles using Surge: https://github.com/devfile/docs/pull/106

However, right here https://github.com/devfile/docs/pull/116, the CI fails and the preview comment is not being generated. Here are the CI logs:

   Running as afc163+surge-preview@gmail.com (Student)

        project: ./out/docs
         domain: devfile-docs-preview-pr-116.surge.sh

     encryption: *.surge.sh, surge.sh (136 days)
             IP: 138.197.235.123

   Success! - Published to devfile-docs-preview-pr-116.surge.sh

Error: Resource not accessible by integration

While browsing through the GitHub community, I discovered this: https://github.community/t/github-actions-are-severely-limited-on-prs/18179

However, I did not find such problems on other projects using the same action. Can I get a better direction on how I can solve this problem? Thanks a lot!

HarshCasper commented 2 years ago

cc: @afc163

tbouffard commented 2 years ago

@HarshCasper the issue you are facing is due to the lack of permissions of the GH_TOKEN when the Pull Request is created from a fork. It only has read permissions whereas write permissions are required to create or update a Pull Request comment.

For more details, you can have a look at #146 and #198 I previously provided detailed information about how the action behaves in such case: https://github.com/process-analytics/bpmn-visualization-js/issues/1279#issuecomment-832764355

About making the action work when the Pull Request is created from a fork repository, there is currently no solution provided by the surge-preview action. An issue is opened about this topic: #124 and alternatives exist but they are based on custom GitHub workflows, see https://github.com/antvis/vis-dashboard/pull/21/files or https://github.com/debezium/debezium.github.io/blob/e462f753d264f97fb0d1a64b52f7fcec0b675875/.github/workflows/surge-preview.yml

tbouffard commented 6 months ago

124 has been fixed, so it is possible to run surge-preview in a workflow triggered by a workflow_run event