Skip to content

[BugWars] Deployment Pipeline for v1.0.48 #254

[BugWars] Deployment Pipeline for v1.0.48

[BugWars] Deployment Pipeline for v1.0.48 #254

name: Process Atlas Commands
on:
issues:
types: [opened]
env:
atlas_action: none
YTID: ''
GENRE: ''
TITLE: ''
jobs:
process_issue:
name: 'Process Issue'
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
outputs:
matched_action: ${{ steps.title-parser.outputs.action }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
npm install @kbve/devops
- name: Check title of the ticket
id: title-parser
uses: actions/github-script@v7
with:
script: |
const { _$gha_kbve_ActionProcess } = require('@kbve/devops');
const title = context.payload.issue.title;
try {
const action = _$gha_kbve_ActionProcess(title);
core.setOutput('action', action);
core.setOutput('error', false);
} catch (error) {
core.setOutput('action', 'none');
core.setOutput('error', true);
}
- name: Debug matched action
run: |
echo "Matched action is: ${{ steps.title-parser.outputs.action }}"
handle_atlas:
name: 'Handle Atlas Ticket'
runs-on: ubuntu-latest
needs: ['process_issue']
permissions:
issues: write
contents: read
if: needs.process_issue.outputs.matched_action == 'atlas_action'
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
npm install @kbve/devops
- name: Atlas Debug Comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/github-script@v7
with:
script: |
const { _$gha_createIssueComment } = require('@kbve/devops');
const body = '[DEBUG] Processing [Atlas](https://kbve.com/project/atlas/) Action v0.0.11';
await _$gha_createIssueComment(github, context, body);
handle_music:
name: 'Handle Music Ticket'
runs-on: ubuntu-latest
needs: ['process_issue']
permissions:
issues: write
contents: read
if: needs.process_issue.outputs.matched_action == 'music_action'
outputs:
YTID: ${{ steps.groq-call.outputs.YTID }}
TITLE: ${{ steps.groq-call.outputs.TITLE }}
GENRE: ${{ steps.groq-call.outputs.GENRE }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
npm install @kbve/devops
# - name: Music Debug Comment
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# uses: actions/github-script@v7
# with:
# script: |
# const { _$gha_createIssueComment } = require('@kbve/devops');
# const body = '[DEBUG] Processing [Music](https://kbve.com/music/) Action v0.0.11';
# await _$gha_createIssueComment(github, context, body);
- name: Call Groq for Music
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
KBVE_API: ''
id: groq-call
uses: actions/github-script@v7
with:
script: |
const { _groq, extractYoutubeId, _$gha_createIssueComment, _$gha_removeLabel, _$gha_addLabel, _$gha_verifyMatrixLabel } = require('@kbve/devops');
const system = '01J0YEVWK8ZA1Z0Q8B0GDG6871';
const message = context.payload.issue.body;
const kbve_api = process.env.KBVE_API;
const model = 'mixtral-8x7b-32768';
const sanitizationLevel = 4;
try {
const response = await _groq(system, message, kbve_api, model, sanitizationLevel);
const formattedResponse = JSON.stringify(response, null, 2);
const _stage_1_body = `[DEBUG](https://kbve.com/application/git/) Processing [Music](https://kbve.com/music/) Action v0.0.11 - Atlas Music Response:\n\`\`\`json\n${formattedResponse}\n\`\`\``;
await _$gha_createIssueComment(github, context, _stage_1_body);
const content = response.choices[0].message.content;
const YTID = extractYoutubeId(message);
const jsonMatch = content.match(/```json\n([\s\S]*?)\n```/);
const extractedJson = jsonMatch ? jsonMatch[1] : null;
let extractedInfoComment = `Dear Lord Commander:\n\`\`\`\n${content}\n\`\`\`\n\n`;
extractedInfoComment += "Extracted Song Information:\n";
if (extractedJson) {
extractedInfoComment += `\`\`\`json\n${extractedJson}\n\`\`\``;
} else {
extractedInfoComment += "Unable to extract song information from the response.";
}
await _$gha_createIssueComment(github, context, extractedInfoComment);
await _$gha_removeLabel(github, context, '0');
if(extractedJson) {
const extractedInfo = JSON.parse(extractedJson);
core.setOutput('YTID', extractedInfo.YTID || extractedInfo.youtube_id || YTID);
core.setOutput('TITLE', extractedInfo.title || '');
core.setOutput('GENRE', (extractedInfo.genre || '').toLowerCase());
await _$gha_addLabel(github, context, '2');
} else {
await _$gha_addLabel(github, context, '1');
}
} catch (error) {
await _$gha_createIssueComment(github, context, `Error processing groq request: ${error.message}`);
}
execute_music_action:
name: 'Execute Music Action'
runs-on: ubuntu-latest
needs: ['handle_music']
permissions:
id-token: write
contents: write
packages: write
issues: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: dev
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
- name: Install pnpm dependencies
run: pnpm install
- name: Use Extracted Variables
run: |
echo "YTID: ${{ needs.handle_music.outputs.YTID }}"
echo "TITLE: ${{ needs.handle_music.outputs.TITLE }}"
echo "GENRE: ${{ needs.handle_music.outputs.GENRE }}"
- name: KBVE Shell - Execute Music Edit for Jukebox
uses: ./.github/actions/kbve-shell
with:
flag: "-nx kbve.com:music --args=\"--file=${{ needs.handle_music.outputs.GENRE }} --title='${{ needs.handle_music.outputs.TITLE }}' --ytid=${{ needs.handle_music.outputs.YTID }}\""
create_pull_request: true
github_token: ${{ secrets.GITHUB_TOKEN }}
pull_request_title: 'music-action-ytid-${{ needs.handle_music.outputs.YTID }}'
pull_request_body: |
Execution of [Music](https://kbve.com/music/) Action.
[Link to the issue ticket](${{
github.event.issue.html_url
}})