Issue to PR Automation #13
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: Issue to PR Automation | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
create_pr: | |
if: contains( toJson( github.event.issue.labels ), '"prompt"' ) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up Git Config | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Create Branch | |
id: branch_name | |
run: | | |
BRANCH_NAME="issue-${{ github.event.issue.number }}" | |
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
git checkout -b $BRANCH_NAME | |
- name: Debug Branch Name | |
run: | | |
echo "Branch name is: ${{ steps.branch_name.outputs.branch }}" | |
- name: Create File from Issue | |
run: | | |
echo '${{ toJson(github.event.issue.body) }}' | jq -r '.' > "issue-${{ github.event.issue.number }}.md" | |
git add . | |
git commit -m "Add issue content for #${{ github.event.issue.number }}" | |
- name: Push Branch | |
run: | | |
git push origin HEAD | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ steps.branch_name.outputs.branch }} | |
base: main # Ensure this is the correct base branch | |
title: "PR for Issue #${{ github.event.issue.number }}" | |
body: | | |
This pull request addresses Issue #${{ github.event.issue.number }}. | |
Automatically generated by GitHub Actions. |