GitHub Action move issue on project when issue is linked to a Pull Request

1k Views Asked by At

I am trying to automate my project boards. I would like an action to trigger when someone opens a Pull Request and links it to a issue on the board, then the issue would be moved to "In Review".

I imagine once I trigger by a pull_request, this information would be seen on the given environment variables. But I dumped all of them and I could not find any reference to the issue I am linking and would like to move on the project board.

Can someone give me some light on what I could do to achieve this result?

2

There are 2 best solutions below

1
Sascha On

First you can reference an issue in your commit message described in the documentation. Then you can set up built-in automations for the project board. If you then push something to your repository and create a merge request, the issue should be automatically linked and moved to the column "In Review".

0
Brian Leishman On

We actually have a github action that does this for us now, it looks something like

name: Callable Front End Issue Tracker

on:
  workflow_call:

jobs:
  manage-project:
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - name: Move PR to Review Needed
        uses: leonsteinhaeuser/[email protected]
        if: ${{ github.event_name == 'pull_request_target' && github.event.action == 'review_requested' }}
        with:
          gh_token: ${{ secrets.SMG_TOKEN }}
          organization: MyOrg
          project_id: 3
          resource_node_id: ${{ github.event.pull_request.node_id }}
          move_related_issues: true
          status_value: 'Dev: Review Needed ' # Target status

Running the actions in debug mode helped a ton with seeing what the event names and actions names were supposed to be.