Skip to content

Conversation

AdarshRawat1
Copy link
Owner

@AdarshRawat1 AdarshRawat1 commented Jul 27, 2024

Failing to preview webpage from external Forks

To handle comments on pull requests from forks in GitHub Actions, you need to address the limitations related to the permissions of the GitHub token (GITHUB_TOKEN). When a workflow runs on a pull request from a forked repository, the default GITHUB_TOKEN has read-only permissions, which prevents it from commenting on issues or pull requests.

To overcome this, you can use a personal access token (PAT) with the necessary permissions instead of the default GITHUB_TOKEN.

Here's how you can update your workflow to use a PAT:

Create a Personal Access Token (PAT):

  • Go to your GitHub account settings.
  • Navigate to "Developer settings" and then to "Personal access tokens."
  • Generate a new token with repo and workflow permissions.
  • Store the PAT in GitHub Secrets:

Go to your repository settings.

  • Navigate to "Secrets and variables" -> "Actions."
  • Add a new secret named PAT_TOKEN and paste the PAT you created.
  • Update your workflow to use the PAT:
  - name: Comment on PR
    uses: hasura/comment-progress@v2.2.0
    if: github.event_name == 'pull_request'
    with:
      github-token: ${{ secrets.PAT_TOKEN }}
      repository: ${{ github.repository }}
      number: ${{ github.event.number }}
      id: deploy-preview
      message: " **🚀 Deployment of preview started...**"

@AdarshRawat1 AdarshRawat1 marked this pull request as ready for review July 27, 2024 16:39
Repository owner deleted a comment from github-actions bot Jul 27, 2024
Copy link

github-actions bot commented Jul 27, 2024

Deployment of preview started...**
A preview of this PR is available at: Preview Link githubloading\n\n 📂 View the source code here: https://github.com/AdarshRawat1/P4c-Documentation-Hosting/tree/gh-pages/pr-preview/10/

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.

1 participant