shwld
Invalid Date

GitHub ActionsでPullRequestを自動生成する

割とStaging確認をしてAcceptしたやつだけ本番に反映するというフローを取りたいことがあります。

Gitフローはちょっと重いし、GitHubフローもその辺やるにはFeature毎の環境をたてるとかしないと行けなさそうでつらい

stagingブランチとmainブランチにとりあえず分けたのですが、PullRequestを作るのが面倒くさかったので自動化しました

yml
name: pullrequest

on:
  push:
    branches:
      - 'feature/**'

jobs:
  pullrequest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJSON(github) }}
        run: echo "$GITHUB_CONTEXT"
      - name: Extract branch name
        shell: bash
        run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/feature/}"
        id: extract_branch
      - name: Create Pull Request
        uses: repo-sync/pull-request@v2
        with:
          destination_branch: "staging"
          github_token: ${{ secrets.GITHUB_TOKEN }}
          pr_title: "[#${{ steps.extract_branch.outputs.branch }}] "
          pr_body: |
            https://www.pivotaltracker.com/story/show/${{ steps.extract_branch.outputs.branch }}
          pr_label: "staging"
          pr_assignee: ${{ github.actor }}
      - name: Create Pull Request for Production
        uses: repo-sync/pull-request@v2
        with:
          destination_branch: "main"
          github_token: ${{ secrets.GITHUB_TOKEN }}
          pr_title: "[#${{ steps.extract_branch.outputs.branch }}] "
          pr_body: |
            https://www.pivotaltracker.com/story/show/${{ steps.extract_branch.outputs.branch }}
          pr_label: "production"
          pr_assignee: ${{ github.actor }}

書いた人

shwld
shwldLV: 106
ATK32620
DEF30929
SPD38392
HIT95
AVD19
CRI20

他の投稿を見る

もっと見る