Created
July 5, 2025 23:50
-
-
Save memory-lovers/0d1b46c7a07dbc6da50c7af30dce46fa to your computer and use it in GitHub Desktop.
GitHub Actions: ブランチ作成時に自動でPRを作成
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 自動PR作成 | |
| on: | |
| push: | |
| branches: | |
| - '*/**' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| create-pr: | |
| runs-on: ubuntu-latest | |
| # ブランチ作成時のみ実行 | |
| if: github.event.created | |
| steps: | |
| - name: チェックアウト | |
| uses: actions/checkout@v4 | |
| - name: PRを作成 | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # ブランチ名からPRタイトルを生成 | |
| BRANCH_NAME="${GITHUB_REF#refs/heads/}" | |
| PR_TITLE=$(echo "$BRANCH_NAME" | sed 's/^[^\/]*\///') | |
| PR_TITLE=$(echo "$PR_TITLE" | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g') | |
| gh pr create \ | |
| --title "$PR_TITLE" \ | |
| --body-file .github/pull_request_template.md \ | |
| --base main \ | |
| --head "$BRANCH_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment