toolkit icon indicating copy to clipboard operation
toolkit copied to clipboard

github.context.payload.pull_request.title always remains the same when rerunning action.

Open mvashishtha opened this issue 3 years ago • 6 comments

Describe the bug

I am using a github action triggered by pull requests that is basically doing:

const github = require('@actions/github');
const pullRequestTitle = github.context.payload.pull_request.title;

The full code is here.

When I update the PR title after the action runs once, then rerun the action, the action reuses the old PR title! The result is that the action that is supposed to check my PR title can only be used once per commit. I have to push an empty commit to get the action to use the new PR title.

Sample runs: https://github.com/modin-project/modin/actions/runs/3231387461/jobs/5291018196

To Reproduce Steps to reproduce the behavior:

  1. Add this to .github/workflows/ci-required.yml in some github project:
name: ci-required
on: pull_request
jobs:
  check-pr-title:
    runs-on: ubuntu-latest
    steps:
    - uses: Slashgear/[email protected]
      with:
        regexp: '^(?:FEAT|DOCS|FIX|REFACTOR|TEST|PERF)-#\d+:'
  1. Make a PR with valid title, e.g. TEST-#4982: Require format for PR descriptions instead of commit descriptions
  2. See the check-pr-title job pass, e.g. here
  3. change PR title so it's invalid, e.g. "TESTz-#4982: Require format for PR descriptions instead of commit descriptions"
  4. rerun check-pr-title job in github UI
  5. see check-pr-title job pass even though PR title is now invalid
  6. push empty commit to branch
  7. see check-pr-title job fail because it uses updated PR title

Expected behavior After I update PR title and re-run Github Action, action should use updated PR title.

mvashishtha avatar Oct 12 '22 05:10 mvashishtha

the same problem, did it work out?

caoxing9 avatar Dec 28 '22 08:12 caoxing9

@MikeCxx I haven't found a solution yet.

mvashishtha avatar Dec 28 '22 23:12 mvashishtha

I don't think there's an answer, and I kinda think it's by design to keep a consistent view at a given commit. But there are a few loopholes.

I've put in documentation that if someone wants to get the updated PR text, they have to push an empty commit.

There's another option too. I don't think this should work, because it violates the consistency of the design, but if you close and re-open the PR, it will run the checks with the updated PR title.

ogreface avatar Jan 02 '23 16:01 ogreface

Have you tried?

on: pull_request: types: [opened, edited]

rodricke avatar Apr 19 '23 10:04 rodricke

Have you tried?

on: pull_request: types: [opened, edited]

This works for the problem at hand, but then any further commits added to the PR under this workflow do not kickoff the GHA again.

So instead, just add synchronized to the list as well, three in total - and this workaround is complete.

I've implemented this (title action) as a separate workflow for the same event type (in my case, pull requests to master) to avoid running the full gambit of CI/CD that traditionally is kicked off for PRs in my project.

So now the title action gets kicked off in tandem, but a commit is not necessary to update the github context.

joshua-temple avatar May 03 '23 14:05 joshua-temple

I have the same problem with github.context.payload.pull_request.requested_reviewers when i add or remove reviewers.

j1myx avatar Oct 13 '24 23:10 j1myx