Programacao

Github Actions - Auto Pull Request

Galera, recentemente disponibilizei na marketplace do GitHub,

uma action para o GitHub actions, Que gera tag release e auto release para seus projetos.

Pois bem, agora estou disponibilizando uma action que gera Auto Pull Request para suas pipe, baseada em outras do mesmo gênero,é possível adicionar aprovadores, assinantes e trabalhar com templates no body.

Um conjunto de actions que adianta muito a sua vida e sua jornada DevOps.

Peço quem usa GitHub actions em seus projetos seja particulares ou corporativos de essa força.

Se tiver qualquer bug, reclamação, sugestão choros e lamentações kkkkkk pode chamar nas formas de contato do website.

Ela é baseada em outra do mesmo gênero, porém fiz algumas correções atualizações e processos de segurança. 🤜🏽🤛🏽

Auto Pull request: https://github.com/marketplace/actions/auto-pull-request

Auto Release: https://github.com/marketplace/actions/automatic-releases-js

Segue abaixo o seu Readme.md com forma de uso.

GitHub Pull Request

A GitHub Action for creating pull requests.

Features

  • Create pull requests
  • Create pull requests on other repos
  • Add reviewers, assignees, labels, or milestones
  • Customize pull request title and body
  • Retrieve the existing pull request url if a pull request already exists

Usage

GitHub Actions

# File: .github/workflows/pull-request.yml

on:
 push:
   branches:
   - develop

jobs:
 pull-request:
   runs-on: ubuntu-latest
   steps:
   - uses: actions/checkout@v3
   - name: pull-request
   uses: diillson/auto-pull-request@latest
     with:
       destination_branch: "main"

This will automatically create a pull request from develop to main.

Advanced options

on:
 push:
   branches:
   - "feature*"  # Support wildcard matching

jobs:
 pull-request:
   runs-on: ubuntu-latest
   steps:
   - uses: actions/checkout@v3
   - name: pull-request
   uses: diillson/auto-pull-request@latest
     with:
       source_branch: ""                                 # If blank, default: triggered branch
       destination_branch: "main"                      # If blank, default: master
       pr_title: "Pulling ${{ github.ref }} into master" # Title of pull request
       pr_body: |                                        # Full markdown support, requires pr_title to be set
         :crown: *An automated PR*

_Created by [diillson/auto-pull-request](https://github.com/diillson/auto-pull-request)_
       pr_template: ".github/PULL_REQUEST_TEMPLATE.md"   # Path to pull request template, requires pr_title to be set, excludes pr_body
       pr_reviewer: "diillson,worker"                         # Comma-separated list (no spaces)
       pr_assignee: "diillson,worker"                         # Comma-separated list (no spaces)
       pr_label: "auto-pr"                               # Comma-separated list (no spaces)
       pr_milestone: "Milestone 1"                       # Milestone name no Required it is comment
       pr_draft: true                                    # Creates pull request as draft
       pr_allow_empty: true                              # Creates pull request even if there are no changes
       github_token: ${{ secrets.CUSTOM_GH_TOKEN }}      # If blank, default: secrets.GITHUB_TOKEN

Third-party repositories

Since it's possible to checkout third-party repositories, you can either define destination_repository manually or letthis action automatically pick up the checked out repository.

jobs:
 pull-request:
   runs-on: ubuntu-latest
   steps:
   - uses: actions/checkout@v2
     with:
       repository: "octocat/hello-world"
   - name: pull-request
   uses: diillson/auto-pull-request@latest
     with:
       destination_branch: "main"
       github_token: ${{ secrets.GITHUB_TOKEN }}
     # destination_repository: "octocat/hello-world" <- You can also do this but not necessary

Priority will be set as follows:

  1. destination_repository (Manually set)
  2. Checked out repository
  3. Repository that triggered the action (GITHUB_REPOSITORY)

Outputs

The following outputs are available: pr_url, pr_number, pr_created ("true"|"false"), has_changed_files ("true"|"false").

on:
 push:
   branches:
   - develop

jobs:
 pull-request:
   runs-on: ubuntu-latest
   steps:
   - uses: actions/checkout@v3
   - name: pull-request
     id: open-pr
     uses: diillson/auto-pull-request@latest
     with:
       destination_branch: "main"
       github_token: ${{ secrets.GITHUB_TOKEN }}
   - name: output-url
     run: echo ${{steps.open-pr.outputs.pr_url}}
   - name: output-number
     run: echo ${{steps.open-pr.outputs.pr_number}}
   - name: output-created
     run: echo ${{steps.open-pr.outputs.pr_created}}
   - name: output-has-changed-files
     run: echo ${{steps.open-pr.outputs.has_changed_files}}

Docker Container Image Usage

Sometimes you might want to use a pre-built container image directly. This could result in faster runs and prevent needlessly rebuilding container images over-and-over on self-hosted runners.

on:
 push:
   branches:
   - develop

jobs:
 pull-request:
   runs-on: ubuntu-latest
   steps:
   - uses: actions/checkout@v2
   - name: pull-request
   uses: docker://public.ecr.aws/y2v3z0w4/pullrequest:v1
     with:
       destination_branch: "main"
       github_token: ${{ secrets.GITHUB_TOKEN }}         # Required to use container image

Notes:

Event Triggers

The GitHub Actions framework allows you to trigger this (and other) actions on many combinations of events. For example, you could create specific pre-releases for release candidate tags (e.g *-rc*), generate releases as changes land on master (example above), nightly releases, and much more. Read through Workflow syntax for GitHub Actions for ideas and advanced examples.

Versioning

Every commit that lands on master for this project triggers an automatic build as well as a tagged release called latest. If you don't wish to live on the bleeding edge you may use a stable release instead. See releases for the available versions.

- uses: "diillson/auto-pull-request@<VERSION>"

How to get help

The main README for this project has a bunch of information related to debugging & submitting issues. If you're still stuck, try and get a hold of me on website and I will do my best to help you out.

License

The source code for this project is released under the MIT License. This project is not associated with GitHub.