Skip to content

Call workflows on the other repository with GITHUB_TOKEN #351

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

Closed
shmpwk opened this issue Mar 11, 2023 · 2 comments
Closed

Call workflows on the other repository with GITHUB_TOKEN #351

shmpwk opened this issue Mar 11, 2023 · 2 comments

Comments

@shmpwk
Copy link

shmpwk commented Mar 11, 2023

Is your feature request related to a problem? Please describe.

As I understand, workflow_dispatch and repository_dispatch with GITHUB_TOKEN can call the other workflow.
However it seems we cannot call the workflow on an other repository.

The example is introduced at GitHub Actions: Use the GITHUB_TOKEN with workflow_dispatch and repository_dispatch

name: Create Workflow Dispatch

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger Workflow
        uses: actions/github-script@v6
        with:
          script: |
            github.rest.actions.createWorkflowDispatch({
              owner: context.repo.owner,
              repo: context.repo.repo,
              workflow_id: 'test.yml',
              ref: 'main',
            })

Describe the solution you'd like
call the workflow on an other repository.

Describe alternatives you've considered
Currently I end up using personal access token or Github Apps instead of GITHUB_TOKEN

Additional context
Add any other context or screenshots about the feature request here.

@mjpieters
Copy link
Contributor

Your example workflow is not triggering a workflow on another repository, it uses context.repo.repo. The automatic GITHUB_TOKEN permissions never extend to other repositories, so I wouldn't expect you to be able to trigger a workflow in another repo with one, no.

This is the unfortunately not the right place to report issues with API permissions, unless you can show that you are able to trigger the workflow using the same token and octokit but not using this action. This action just bundles pcakages from @action/toolkit and lets you write javascript code inline in your workflow.

@shmpwk
Copy link
Author

shmpwk commented Mar 31, 2023

Got it, thank you!

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

No branches or pull requests

2 participants