devlato/async-wait-until

View on GitHub
.github/workflows/pr.yml

Summary

Maintainability
Test Coverage
name: PR

on:
  push:
    branches-ignore:
      - master
      - gh-pages
    tags-ignore:
      - '*'

jobs:
  create_pull_request:
    name: Create or update a pull request
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          ref: '${{ github.event.pull_request.head.sha }}'
          persist-credentials: false
          fetch-depth: 0
          set-safe-directory: 'true'
      - name: Create a pull request
        uses: devops-infra/action-pull-request@v0.5.5
        with:
          github_token: '${{ secrets.GITHUB_TOKEN }}'
          target_branch: '${{ secrets.NEW_PR_DEFAULT_DESTINATION_BRANCH }}'
          title: '${{ env.PR_TITLE }}'
          body: '${{ env.PR_DESCRIPTION }}'
          template: '.github/PULL_REQUEST_TEMPLATE/default.md'
          reviewer: '${{ secrets.NEW_PR_DEFAULT_REVIEWERS }}'
          assignee: '${{ secrets.NEW_PR_DEFAULT_ASSIGNEES }}'
          label: '${{ secrets.NEW_PR_DEFAULT_LABELS }}'
          milestone: '${{ secrets.NEW_PR_DEFAULT_MILESTONE }}'
          ignore_users: 'dependabot'
      - name: Generate the changelog for this pull request
        id: generate-changelog
        run: |
          CURRENT_BRANCH="${GITHUB_SHA}"
          pr_title="$( git log --reverse --format='%s' "origin/${MAIN_BRANCH}".."${CURRENT_BRANCH}" | head -n 1 )"
          pr_changelog="$( git log --reverse --format='- (%h) %s (%an)' "origin/${MAIN_BRANCH}".."${CURRENT_BRANCH}" )"
          pr_description=$( echo "## ${pr_title}"; echo; echo; echo "### Changelog"; echo; echo "${pr_changelog}" )

          echo "PR_TITLE<<EOF" >> ${GITHUB_ENV}
          echo "${pr_title}" >> ${GITHUB_ENV}
          echo 'EOF' >> ${GITHUB_ENV}

          echo "PR_DESCRIPTION<<EOF" >> ${GITHUB_ENV}
          echo "${pr_description}" >> ${GITHUB_ENV}
          echo 'EOF' >> ${GITHUB_ENV}
        env:
          MAIN_BRANCH: '${{ secrets.NEW_PR_DEFAULT_DESTINATION_BRANCH }}'
      - name: Update pull request
        uses: kt3k/update-pr-description@v1.0.4
        if: always()
        with:
          pr_title: '${{ env.PR_TITLE }}'
          pr_body: '${{ env.PR_DESCRIPTION }}'
          github_token: '${{ secrets.GITHUB_TOKEN }}'