From a756a1a852bc4e03980bdb6a1e8e745337bcd961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Mart=C3=ADn?= Date: Fri, 20 Dec 2024 12:28:04 +0100 Subject: [PATCH] Update issue-to-pr.yml --- .github/workflows/issue-to-pr.yml | 69 +++++-------------------------- 1 file changed, 10 insertions(+), 59 deletions(-) diff --git a/.github/workflows/issue-to-pr.yml b/.github/workflows/issue-to-pr.yml index 45e1721..cdf589b 100644 --- a/.github/workflows/issue-to-pr.yml +++ b/.github/workflows/issue-to-pr.yml @@ -1,4 +1,4 @@ -name: issue-to-pr-automation +name: Issue to PR Automation on: issues: @@ -16,79 +16,30 @@ jobs: run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' - - - name: Extract Issue Data - id: extract_data - run: | - echo "Extracting data from issue body" - - # Set PROMPT_NAME to the issue title - prompt_name="${{ github.event.issue.title }}" - echo "PROMPT_NAME=$prompt_name" >> $GITHUB_ENV - - # Extract author - author="$(echo "${{ github.event.issue.body }}" | awk '/^### Author$/,/^###/{if ($0 !~ /^###/ && $0 != "") print}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" - echo "AUTHOR=$author" >> $GITHUB_ENV - - # Extract tags - tags="$(echo "${{ github.event.issue.body }}" | awk '/^### Tags$/,/^###/{if ($0 !~ /^###/ && $0 != "") print}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" - echo "TAGS=$tags" >> $GITHUB_ENV - - # Extract prompt content - prompt_content="$(echo "${{ github.event.issue.body }}" | awk '/^### Prompt$/,/^$/{if ($0 !~ /^###/ && $0 != "") print}' )" - echo "PROMPT_CONTENT<> $GITHUB_ENV - echo "$prompt_content" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - 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 Extracted Data + git checkout -b $BRANCH_NAME + - name: Debug Branch Name run: | - echo "Prompt Name: ${{ env.PROMPT_NAME }}" - echo "Author: ${{ env.AUTHOR }}" - echo "Tags: ${{ env.TAGS }}" - echo "Prompt Content:" - echo "${{ env.PROMPT_CONTENT }}" - + echo "Branch name is: ${{ steps.branch_name.outputs.branch }}" - name: Create File from Issue run: | - # Sanitize prompt name to create a valid file name - FILE_NAME="$(echo "${{ env.PROMPT_NAME }}" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+|-+$//g')" - FILE_PATH="aida-prompts/_prompts/${FILE_NAME}.md" - - echo "Creating file at $FILE_PATH" - - mkdir -p "$(dirname "$FILE_PATH")" - - cat > "$FILE_PATH" < "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 - title: "Add Prompt: ${{ env.PROMPT_NAME }}" + base: main # Ensure this is the correct base branch + title: "PR for Issue #${{ github.event.issue.number }}" body: | - Adds a new prompt from Issue #${{ github.event.issue.number }}. + This pull request addresses Issue #${{ github.event.issue.number }}. Automatically generated by GitHub Actions.