actions / actions/toolkit

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

Open
#1,204 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

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/action-check-pr-title@v3.0.0
      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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the @actions/github context access shown in the issue and the linked action-check-pr-title src/run.js, then reproduce the behavior using the .github/workflows/ci-required.yml workflow. Compare the pull_request.title available on the first run, a rerun, and after an empty commit; done means rerunning after a title change evaluates the updated title.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.