try roo cline #379
This file contains 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: generate_pr_from_issue | |
on: | |
issues: | |
types: [opened, edited, labeled, unlabeled] | |
concurrency: | |
group: create_pr-from-issue-${{ github.event.issue.number }} | |
# Do not set "cancel-in-progress: true" here, just queuing will fit | |
jobs: | |
build: | |
if: contains(github.event.issue.labels.*.name, 'article') | |
runs-on: ubuntu-latest | |
env: | |
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
steps: | |
- name: Install dprint | |
run: | | |
curl -fsSL https://dprint.dev/install.sh | sh -s '0.45.0' > /dev/null 2>&1 | |
echo "/home/runner/.dprint/bin" >> "$GITHUB_PATH" | |
- uses: actions/checkout@v4 | |
with: | |
# Needed to specify token for checkout phase, only in push phase is too late | |
# https://github.com/orgs/community/discussions/27072#discussioncomment-3254515 | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- name: debug logging for git remotes | |
run: git remote -v | |
- name: Normalize issue title | |
id: normalizer | |
env: | |
ISSUE_TITLE: ${{ github.event.issue.title }} | |
run: | | |
title="$ISSUE_TITLE" | |
title="${title//\[*\]/}" | |
title=`echo $title | xargs` | |
echo "title=${title// /-}" | tee -a "$GITHUB_OUTPUT" | |
- name: setup go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'tool/go.mod' | |
cache-dependency-path: 'tool/go.sum' | |
- name: install articlegen | |
run: | | |
cd ./tool/articlegen | |
go install . | |
- name: install makepr | |
run: | | |
cd ./tool/makepr | |
go install . | |
- name: commit | |
run: | | |
GITHUB_TOKEN=${TOKEN} articlegen --issue-num=${{ github.event.issue.number }} > 'content/posts/${{ steps.normalizer.outputs.title }}.md' | |
dprint fmt 'content/posts/${{ steps.normalizer.outputs.title }}.md' | |
git config user.email "yosuke.akatsuka@gmail.com" | |
git config user.name "pankona" | |
git switch '${{ steps.normalizer.outputs.title }}' || git switch -c '${{ steps.normalizer.outputs.title }}' | |
git add 'content/posts/${{ steps.normalizer.outputs.title }}.md' | |
git commit -m "add post ${{ steps.normalizer.outputs.title }}" | |
- name: push | |
env: | |
GH_TOKEN: ${{ github.token }} | |
# "--force-with-lease" will not fit for upserting | |
run: | | |
pr_number="$(gh pr list --author "@me" --head '${{ steps.normalizer.outputs.title }}' --state open --json number --jq 'map(.number)[0]')" | |
git push --set-upstream origin "${{ steps.normalizer.outputs.title }}" --force | |
GITHUB_TOKEN=${TOKEN} makepr --base="main" --head='${{ steps.normalizer.outputs.title }}' --pr_number="${pr_number:=0}" --body="Resolves: ${{ github.event.issue.html_url }}" |