Skip to content

Latest commit

 

History

History
116 lines (94 loc) · 3.15 KB

File metadata and controls

116 lines (94 loc) · 3.15 KB

github/git-pr-release

staging ブランチから production ブランチへのリリースPRを自動作成するComposite Actionです。 git-pr-release を使用して、リリースに含まれるPR一覧をチェックリスト形式で本文に含んだPRを作成します。

使用方法

- uses: buffett-code-dev/github-actions/github/git-pr-release@main
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    branch-production: main
    branch-staging: develop

パラメータ

名前 必須 デフォルト 説明
github-token Yes GitHubトークン (pull request write権限が必要)
branch-production Yes 本番ブランチ名
branch-staging Yes ステージングブランチ名
labels release リリースPRに付与するラベル (カンマ区切り)
template リリースPR本文のERBテンプレートファイルのパス

使用例

基本的な使用方法 (定期実行)

name: Create release PR

on:
  schedule:
    - cron: '0 0 * * 1'  # 毎週月曜0時に実行
  workflow_dispatch:

jobs:
  release-pr:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: buffett-code-dev/github-actions/github/git-pr-release@main
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          branch-production: main
          branch-staging: develop

ブランチ名の指定

- uses: buffett-code-dev/github-actions/github/git-pr-release@main
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    branch-production: master
    branch-staging: development

ラベルの指定

- uses: buffett-code-dev/github-actions/github/git-pr-release@main
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    branch-production: main
    branch-staging: develop
    labels: release,hotfix

developへのpush時にも実行

name: Create release PR

on:
  push:
    branches:
      - develop
  schedule:
    - cron: '0 0 * * 1'
  workflow_dispatch:

jobs:
  release-pr:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: buffett-code-dev/github-actions/github/git-pr-release@main
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          branch-production: main
          branch-staging: develop

動作

  1. production ブランチと staging ブランチの差分を確認します
  2. 差分がない場合はスキップします
  3. 差分がある場合、staging → production のリリースPRを作成 (既存のリリースPRがあれば更新) します
  4. リリースPRの本文には、含まれるPRの一覧がチェックリスト形式で記載されます

前提条件

  • actions/checkoutfetch-depth: 0 を指定して全履歴を取得すること
  • ワークフローが pull-requests: write 権限を持っていること