Skip to content

Latest commit

 

History

History
83 lines (69 loc) · 2.19 KB

README.md

File metadata and controls

83 lines (69 loc) · 2.19 KB

Reliable* Pull Request Action

*Only uses built-in GitHub runner commands

Test Action

Synopsis

  1. Create a pull request on a GitHub repository using existing branches.
  2. actions/checkout determins the active repo.

Usage

jobs:
  create-pr:
    name: Test create PR on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
    steps:
      - name: Checkout the repo
        uses: actions/[email protected]

      - name: Create Pull Request
        id: create_pr
        uses: JosiahSiegel/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          title: 'Automated Pull Request'
          sourceBranch: ${{ github.ref_name }}
          targetBranch: 'main'
          body: 'This is an automated pull request.'
          labels: 'automated,pr'
          assignees: 'octocat'

      - name: Output PR URL
        run: echo "The PR URL is ${{ steps.create_pr.outputs.PRURL }}"

Inputs

inputs:
  title:
    description: 'Pull Request Title'
    required: true
  sourceBranch:
    description: 'Source Branch Name'
    required: true
  targetBranch:
    description: 'Target Branch Name'
    required: true
  body:
    description: 'Pull Request Body'
    required: false
  labels:
    description: 'Labels (comma-separated)'
    required: false
  assignees:
    description: 'Assignees (comma-separated)'
    required: false

Outputs

outputs:
  PRURL:
    description: 'The URL of the created pull request'

Requirements

The following permissions must be set for the repository:

  • Settings > Actions > General
    • Workflow permissions
      1. Read and write permissions
      2. Allow GitHub Actions to create and approve pull requests
      3. Save

Alternative is to set jobs.<job_id>.permissions