Skip to content

JavaScript wrapper for `octokit.pulls.create` with provided GitHub Actions Inputs

Notifications You must be signed in to change notification settings

gha-utilities/init-pull-request

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GHA Initialize Pull Request

JavaScript wrapper for octokit.pulls.create with provided GitHub Actions Inputs

Byte size of init-pull-request Open Issues Open Pull Requests Latest commits


Table of Contents


Requirements

Access to GitHub Actions if using on GitHub, or manually assigning environment variables prior to running npm test.


Quick Start

Reference the code of this repository within your own workflow...

on:
  push:
    branches:
      - src-pages

jobs:
  jekyll_build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout source branch for building Pages
        uses: actions/checkout@v2
        with:
          ref: src-pages
          fetch-depth: 10

      - name: Make build destination directory
        run: mkdir -vp ~/www/repository-name

      - name: Jekyll Build
        uses: gha-utilities/jekyll-build@v0.0.4
        with:
          jekyll_github_token: ${{ secrets.JEKYLL_GITHUB_TOKEN }}
          source: ./
          destination: ~/www/repository-name

      - name: Checkout branch for Pull Requesting to GitHub Pages
        uses: actions/checkout@v2
        with:
          ref: pr-pages
          fetch-depth: 1
          submodules: true

      - name: Copy built site files into Git branch
        run: cp -r ~/www/repository-name ./

      - name: Add changes to Git tracking
        run: git add -A .

      - name: Commit changes
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git commit -m 'Updates compiled site files'

      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: pr-pages

      - name: Initialize Pull Request
        uses: gha-utilities/init-pull-request@v0.4.0
        with:
          verbose: true
          pull_request_token: ${{ secrets.GITHUB_TOKEN }}
          head: pr-pages
          base: gh-pages
          title: 'Updates site files from latest Actions build'
          body: >
            Perhaps a multi-line description
            about latest features and such.

Notes

According to OctoKit documentation for octokit.pulls.create...

You cannot submit a pull request to one repository that requests a merge to a base of another repository.

... and...

For cross-repository pull requests in the same network, namespace head with a user like this: username:branch

      - name: Initialize Pull Request
        uses: gha-utilities/init-pull-request@v0.4.0
        with:
          verbose: true
          pull_request_token: ${{ secrets.GITHUB_TOKEN }}
          head: 'your-name:pr-pages'
          base: gh-pages
          title: 'Updates site files from latest Actions build'
          body: >
            Perhaps a multi-line description
            about latest features and such.

To assign a different repository modify the GITHUB_REPOSITORY environment variable...

      - name: Initialize Pull Request
        uses: gha-utilities/init-pull-request@v0.4.0
        env:
          GITHUB_REPOSITORY: maintainer/repo-name
        with:
          verbose: true
          pull_request_token: ${{ secrets.GITHUB_TOKEN }}
          head: your-name:pr-pages
          base: gh-pages
          title: 'Updates site files from latest Actions build'
          body: >
            Perhaps a multi-line description
            about latest features and such.

Inputs marked [Experimental] within action.yaml file (such as maintainer_can_modify and draft) when defined may cause issues, thus it is a good idea to also define debug: true when testing, eg...

      - name: Initialize Pull Request
        uses: gha-utilities/init-pull-request@v0.4.0
        env:
          GITHUB_REPOSITORY: maintainer/repo-name
        with:
          verbose: true
          debug: true
          draft: false
          maintainer_can_modify: true
          pull_request_token: ${{ secrets.GITHUB_TOKEN }}
          head: your-name:pr-pages
          base: gh-pages
          title: 'Updates site files from latest Actions build'
          body: >
            Perhaps a multi-line description
            about latest features and such.

This repository may not be feature complete, or fully operational, Pull Requests are most welcomed ;-)


Attribution


License

Legal bits of Open Source software. Note the following license does not necessarily apply to any dependencies of this repository, see licensing and documentation for those within there respective sub-directories under node_modules/.

Initialize Pull Request GitHub Actions documentation
Copyright (C) 2023  S0AndS0

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation; version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

About

JavaScript wrapper for `octokit.pulls.create` with provided GitHub Actions Inputs

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Sponsor this project