Old workflow used after commit change?

I’m using pull_request_target to trigger a workflow when a PR is opened and updated. In my testing, I’ve created a PR with develop as the updated branch and master as the branch I want to merge into.

Since I’m using pull_request_target, my understanding is that Actions will use the workflow from the master branch. I’m still building up my workflow bit by bit and fixing the bugs in it. However, what I’m finding is that if I commit the revised workflow back to the master branch and then update the PR so that the action is triggered, it often seems like the previous version of the workflow is used and not the version I’ve just committed.

Am I doing something wrong or am I misunderstanding something about how Actions work?

@pcolmer,

Since I’m using pull_request_target, my understanding is that Actions will use the workflow from the master branch.

Yes, your understanding is correct.
However, there are more things you also need to know:

  1. When opening a PR, the base commit SHA (github.event.pull_request.base.sha) generally will point to the latest commit on the target branch of the PR, if the source branch is up-to-date with the target branch. The base commit SHA normally is fixed and not automatically changed.

  2. During the PR is Open, if you push some new commits to the target branch of the PR, the base commit SHA also will not be changed automatically. At this time, if you want the base commit SHA can point to the latest commit on the target branch, you can do like as this:

    • If you have set the Branch protection rule for the target branch (master in your case) and enabled the option “Require branches to be up to date before merging”, you will see the “Update branch” button on the PR. Click the button to sync the new commits from the target branch to the source branch and the PR merge branch. After that, the base commit SHA will point to the latest commit on the target branch.

1 Like

Brilliant! Thank you for that explanation and the solutions offered. It makes sense to me now :slight_smile: