Skip to content

Token generated from GitHub App not working with push-to-fork #2848

@AjayJagan

Description

@AjayJagan

Subject of the issue

GitHub App can be used as a service account to generate short-lived tokens in the workflows. While trying to use such a token to create a pull request in a remote repo + push-to-fork, it fails with the error: Resource not accessible by integration
The fork exists in the same org, where the workflow runs and has the GH app installed in the fork repo.

Steps to reproduce

name: "test"
on:
  workflow_dispatch:
jobs:
  test:
    name: Test gh app token pr creation
    runs-on: ubuntu-latest
    steps:
      - uses: tibdex/github-app-token@v1
        id: generate-token
        with:
          app_id: ${{ secrets.APP_ID }}
          private_key: ${{ secrets.APP_PRIVATE_KEY }}
      - name: Checkout remote repo
        uses: actions/checkout@v4
        with:
          token: ${{ steps.generate-token.outputs.token }}
          repository: <remote-repo-org>/<remote-repo-name>

     # Make changes to files

      - name: Create PR
        uses: peter-evans/create-pull-request@v6
        with:
          token: ${{ steps.generate-token.outputs.token }}
          push-to-fork: <fork-repo-org>/<fork-repo-name> # This repo exists in the same org as the workflow and has the GH App installed.
          commit-message: <commit-message>
          delete-branch: true
          title: <title>

If this issue is describing a possible bug please provide (or link to) your GitHub Actions workflow.

Any help would be much appreciated :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions