메인 커밋이 진행되면 RELEASE MERGE PR을 만드는 GitHub Action

main 분기 commit가 전진하면, foo/main에 PR를 만드는 job.
GitHub CLI 사용해 간단하게 쓸 수 있다.
on:
  push:
    branches:
      - main

jobs:
  create_release_merge_PR:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v2

      # See: https://github.com/cli/cli/blob/trunk/docs/install_linux.md
      - name: install GitHub CLI
        run: |-
          sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
          sudo apt-add-repository https://cli.github.com/packages
          sudo apt update
          sudo apt install gh

      # See: https://cli.github.com/manual/gh_auth_login
      # See: https://cli.github.com/manual/gh_pr_create
      - name: create RELEASE MERGE PR
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |-
          git checkout -b release_merge_for_foo
          git push --force origin release_merge_for_foo
          echo $GITHUB_TOKEN > token.txt
          gh auth login --with-token < token.txt
          gh pr create \
          --title "RELEASE MERGE for foo" \
          --base xxx \
          --body "Auto Generated RELEASE MEREGE PR"

좋은 웹페이지 즐겨찾기