diff --git a/.github/workflows/i-music-process.yml b/.github/workflows/i-music-process.yml new file mode 100644 index 0000000..fe60b5d --- /dev/null +++ b/.github/workflows/i-music-process.yml @@ -0,0 +1,52 @@ +name: Process Music Issues + +on: + issues: + types: [opened] + +permissions: + issues: write + contents: read + +jobs: + process_issue: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check if issue title contains [MUSIC] + run: ./scripts/check_title.sh "${{ github.event.issue.title }}" + + - name: Stop if not a music issue + if: env.is_music_issue == 'false' + run: echo "Not a music issue. Skipping further steps." + + - name: Check for YouTube link in issue body + if: env.is_music_issue == 'true' + run: ./scripts/check_youtube.sh "${{ github.event.issue.body }}" + + - name: Display YouTube link check result + if: env.is_music_issue == 'true' + run: echo "Contains YouTube link: ${{ env.has_youtube_link }}" + + - name: Escape issue body for JSON + if: env.has_youtube_link == 'true' && env.is_music_issue == 'true' + run: ./scripts/escape_issue_body.sh "${{ github.event.issue.body }}" + + - name: Extract and display YouTube ID if link is found + if: env.has_youtube_link == 'true' && env.is_music_issue == 'true' + run: ./scripts/send_payload.sh "${{ env.youtube_id }}" "${{ env.escaped_issue_body }}" + + - name: Post comment to issue + if: env.has_youtube_link == 'true' && env.is_music_issue == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GROQ_OUTPUT: ${{ env.groq_output }} + run: | + COMMENT_BODY_SANITIZED=$(echo "$GROQ_OUTPUT" | sed 's/"/\\"/g') + curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"body\": \"Here is the processed information:\\n\\n\`\`\`bash\\n$COMMENT_BODY_SANITIZED\\n\`\`\`\"}" \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments"