actions / github-script

Write workflows scripting the GitHub API in JavaScript
MIT License
4.24k stars 424 forks source link

`github.rest.git.createRef` does not trigger other workflows #491

Closed RobertoRoos closed 1 month ago

RobertoRoos commented 1 month ago

Describe the bug When pushing a new tag with github.rest.git.createRef on a scheduled job, the tag is successfully created but other workflows that should be triggered by a new tag are not.

To Reproduce I have a scheduled job like this:

on:
    schedule:
        - cron: "49 5 * * *"

jobs:
    find_releases:
        name: Find releases
        runs-on: ubuntu-latest

        steps:

            - uses: actions/github-script@v7
              with:
                  script: |
                      // ...
                      const result_ref = await github.rest.git.createRef({
                          owner: context.repo.owner,
                          repo: context.repo.repo,
                          ref: "refs/tags/" + "v0.0.1",
                          sha: context.sha
                      })

And a build job like this:

on: push

jobs:
  build_wheels:
    steps:
      - uses: actions/checkout@v4
      - <build step>

  publish:
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
    steps:
      - <publish step>

Expected behavior I would expect the tag to be created on the schedule, after which a build and a corresponding publish is triggered.

Desktop (please complete the following information):


The scheduled workflow run from this morning: https://github.com/RobertoRoos/protobuf-protoc-bin/actions/runs/11249037881/job/31275208574
All workflows for that version: https://github.com/RobertoRoos/protobuf-protoc-bin/tree/c737e636f6fbfc626cbcb207d77af7713db50bda/.github/workflows

RobertoRoos commented 1 month ago

Of course I should have searched a bit more, it looks like this is a limit by Github workflows: https://github.com/orgs/community/discussions/27028

RobertoRoos commented 1 month ago

Yup, remedied by changing the pipeline to a personal access token:

            - uses: actions/github-script@v7
              with:
                  # Use a custom Personal Access Token (over the default `GITHUB_TOKEN`) as otherwise it cannot
                  # trigger new workflows.
                  github-token: ${{ secrets.CUSTOM_PAT }}
                  script: |
                      // ...