fix: PR bodyをファイル経由で渡しバッククォートのエスケープ問題を修正 #4
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: Release | |
| on: | |
| push: | |
| branches: [develop] | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - run: bun install --frozen-lockfile | |
| - name: Check for changesets | |
| id: check | |
| run: | | |
| if ls .changeset/*.md 2>/dev/null | grep -v README.md | head -1 > /dev/null 2>&1; then | |
| echo "has_changesets=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_changesets=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Version packages | |
| if: steps.check.outputs.has_changesets == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| bun changeset version | |
| git add . | |
| git commit -m "chore: release packages" || echo "No changes to commit" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate PR body | |
| if: steps.check.outputs.has_changesets == 'true' | |
| run: | | |
| for changelog in $(git diff HEAD~1 --name-only | grep 'CHANGELOG.md$'); do | |
| cat "$changelog" | |
| echo "" | |
| done > /tmp/pr-body.md | |
| - name: Create or update release PR | |
| if: steps.check.outputs.has_changesets == 'true' | |
| run: | | |
| git push origin HEAD:changeset-release/release --force | |
| EXISTING_PR=$(gh pr list --base release --head changeset-release/release --json number --jq '.[0].number') | |
| if [ -n "$EXISTING_PR" ]; then | |
| gh pr edit "$EXISTING_PR" --body-file /tmp/pr-body.md | |
| else | |
| gh pr create \ | |
| --base release \ | |
| --head changeset-release/release \ | |
| --title "chore: release packages" \ | |
| --body-file /tmp/pr-body.md | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |