0

I'm quite a rookie with GitHub Actions so this might be a stupid question: Is there a way to link pull requests with issues (in the UI linked PRs are shown under Development) in Github Actions using Github CLI or octokit/rest.js via actions/github-script?

enter image description here

Background: there is a workflow that creates pull requests. That works fine, only thing missing is the link between issues and corresponding pull requests. I would prefer not to use keywords nor other custom actions from the marketplace.

I've searched in the octokit/rest.js documentation https://octokit.github.io/rest.js/v19 under Issues and Pulls as well as in the GitHub cli documentation https://cli.github.com/manual/gh but couldn't find a solution.

I would like to have a solution either using GitHub Script https://github.com/marketplace/actions/github-script or the command line.

Sly78
  • 1
  • 1

1 Answers1

0

You can use the Add an issue link Action for that.

This Action allows linking issues to Pull Requests. For example:

name: 'Issue Links'
on:
  pull_request:
    types: [opened]

jobs:
  issue-links:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: tkt-actions/add-issue-links@v1.8.1
        with:
          repo-token: '${{ secrets.GITHUB_TOKEN }}' # required
          branch-prefix: 'issue-' # required

This workflow will trigger on Pull Request open and link related issues mentioned in the PR body.

Make sure to set the corresponding permission for the job:

permissions:
  pull-requests: write

For more about these permissions visit the Permissions for the GITHUB_TOKEN.

Andrii Bodnar
  • 1,672
  • 2
  • 17
  • 24