Name:inarix/wait-for-commit
Automatically check if a commit is synchronized on a GitHub pull requests. The GITHUB_TOKEN secret must be provided as the github-token input for the action to work.
Create a workflow file (e.g. .github/workflows/wait-for-commit.yml) that contains a step that uses: inarix/wait-for-commit@v1. Here's an example workflow file:
name: Wait for commiton: pull_request_targetjobs:
build:
runs-on: ubuntu-latestpermissions:
pull-requests: writesteps:
- uses: inarix/wait-for-commit@v1with:
github-token: ${{ secrets.GITHUB_TOKEN }}commit-sha: abcdefCombine with an if clause to only auto-approve certain users. For example, to wait-for-commit [Dependabot][dependabot] pull requests, use:
name: Wait for commiton:
pull_requestjobs:
auto-approve:
runs-on: ubuntu-latestpermissions:
pull-requests: writesteps:
- uses: inarix/wait-for-commit@v1if: github.actor == 'dependabot[bot]'with:
github-token: ${{ secrets.GITHUB_TOKEN }}commit-sha: abcdefIf you want to use this action from a workflow file that doesn't run on the pull_request or pull_request_target events, use the pull-request-number input:
name: Wait for commiton:
workflow_dispatch:
inputs: pullRequestNumberdescription: Pull request number to wait for commitrequired: falsejobs:
wait-for-commit:
runs-on: ubuntu-latestpermissions:
pull-requests: writesteps:
- uses: inarix/wait-for-commit@v1with:
github-token: ${{ secrets.GITHUB_TOKEN }}pull-request-number: ${{ github.event.inputs.pullRequestNumber }}commit-sha: abcdefWhile using hmarr/auto-approve@v2 Github action with an auto-commit before hand, sometimes Github doesn't synchronize on time before auto-approve is ran. Therefore, we wanted a step to check if the commit has been synchronized before auto approving a pull request.
If you're using a CODEOWNERS file, you'll need to give this action a personal access token for a user listed as a code owner. Rather than using a real user's personal access token, you're probably better off creating a dedicated bot user, and adding it to a team which you assign as the code owner. That way you can restrict the bot user's permissions as much as possible, and your workflow won't break when people leave the team.