Skip to content

Call workflows on the other repository with GITHUB_TOKEN #351

Description

@shmpwk

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.

Activity

  1. mjpieters commented on Mar 30, 2023

    @mjpieters
    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.

  2. shmpwk commented on Mar 31, 2023

    @shmpwk
    Author

    Got it, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions