gha-utilities / init-pull-request

JavaScript wrapper for `octokit.pulls.create` with provided GitHub Actions Inputs
4 stars 3 forks source link
github-actions pull-request

GHA Initialize Pull Request

[heading__title]:

gha-initialize-pull-request

"⬆ Top of ReadMe File"

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

[![Byte size of init-pull-request][badgemasterinit_pull_requestsource_code]][init_pull_requestmastersource_code] [![Open Issues][badgeissuesinit_pull_request]][issuesinit_pull_request] [![Open Pull Requests][badgepull_requests__init_pull_request]][pull_requestsinit_pull_request] [![Latest commits][badgecommitsinit_pull_requestmaster]][commitsinit_pull_request__master]


Table of Contents


Requirements

[heading__requirements]:

requirements

"🏗 What is needed prior to making use of this repository"

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


Quick Start

[heading__quick_start]:

quick-start

"⚡ Perhaps as easy as one, 2.0,..."

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

[notes]:

notes

"🗒 Additional notes and links that may be worth clicking in the future"

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

[heading__attribution]:

attribution

"📇 Resources that where helpful in building this project so far."


License

[heading__license]:

license

"⚖ Legal bits of Open Source software"

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/>.

[badgecommitsinit_pull_request__master]: https://img.shields.io/github/last-commit/gha-utilities/init-pull-request/master.svg

[commitsinit_pull_requestmaster]: https://github.com/gha-utilities/init-pull-request/commits/master "📝 History of changes on this branch"

[init_pull_request__community]: https://github.com/gha-utilities/init-pull-request/community "🌱 Dedicated to functioning code"

[badgeissuesinit_pull_request]: https://img.shields.io/github/issues/gha-utilities/init-pull-request.svg

[issues__init_pull_request]: https://github.com/gha-utilities/init-pull-request/issues "☢ Search for and bump existing issues or open new issues for project maintainer to address."

[badge__pull_requests__init_pull_request]: https://img.shields.io/github/issues-pr/gha-utilities/init-pull-request.svg

[pull_requests__init_pull_request]: https://github.com/gha-utilities/init-pull-request/pulls "🏗 Pull Request friendly, though please check the Community guidelines"

[badgemasterinit_pull_request__source_code]: https://img.shields.io/github/repo-size/gha-utilities/init-pull-request

[init_pull_requestmastersource_code]: https://github.com/gha-utilities/init-pull-request "⌨ Project source code!"