Skip to content

Commit

Permalink
Create i-music-process.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
h0lybyte authored Jun 8, 2024
1 parent 55f111f commit ab3c3b2
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/i-music-process.yml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit ab3c3b2

Please sign in to comment.