Skip to content

[Project Submission] Deepmine-Sentinel #13

[Project Submission] Deepmine-Sentinel

[Project Submission] Deepmine-Sentinel #13

Workflow file for this run

name: Step 0, Welcome
on:
workflow_dispatch:
issues:
types: [opened, edited, labeled]
permissions:
contents: write
issues: write
jobs:
get_current_step:
name: Check current step number
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- id: get_step
run: |
echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT
outputs:
current_step: ${{ steps.get_step.outputs.current_step }}
on_quest_selection:
name: Handle quest selection
needs: get_current_step
if: >-
${{ github.event_name == 'issues' &&
(contains(github.event.issue.title, 'Quest') ||
contains(join(github.event.issue.labels.*.name, ' '), 'quest')) }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine selected quest
id: determine_quest
run: |
TITLE="${{ github.event.issue.title }}"
if [[ "$TITLE" == *"GenAI prototype"* ]]; then
echo "quest=1" >> $GITHUB_OUTPUT
echo "to_step=1" >> $GITHUB_OUTPUT
elif [[ "$TITLE" == *"move to Azure"* ]]; then
echo "quest=2" >> $GITHUB_OUTPUT
echo "to_step=2" >> $GITHUB_OUTPUT
elif [[ "$TITLE" == *"simple chat interface"* ]]; then
echo "quest=3" >> $GITHUB_OUTPUT
echo "to_step=3" >> $GITHUB_OUTPUT
elif [[ "$TITLE" == *"first AI app with RAG"* ]]; then
echo "quest=4" >> $GITHUB_OUTPUT
echo "to_step=4" >> $GITHUB_OUTPUT
elif [[ "$TITLE" == *"explore frameworks"* ]]; then
echo "quest=5" >> $GITHUB_OUTPUT
echo "to_step=5" >> $GITHUB_OUTPUT
elif [[ "$TITLE" == *"build an agent"* ]]; then
echo "quest=6" >> $GITHUB_OUTPUT
echo "to_step=6" >> $GITHUB_OUTPUT
elif [[ "$TITLE" == *"MCP tools"* ]]; then
echo "quest=7" >> $GITHUB_OUTPUT
echo "to_step=7" >> $GITHUB_OUTPUT
elif [[ "$TITLE" == *"automate code reviews"* ]]; then
echo "quest=8" >> $GITHUB_OUTPUT
echo "to_step=8" >> $GITHUB_OUTPUT
elif [[ "$TITLE" == *"create templates"* ]]; then
echo "quest=9" >> $GITHUB_OUTPUT
echo "to_step=9" >> $GITHUB_OUTPUT
else
echo "quest=0" >> $GITHUB_OUTPUT
echo "to_step=1" >> $GITHUB_OUTPUT
fi
- name: Update step based on quest selection
if: steps.determine_quest.outputs.quest != '0'
uses: skills/action-update-step@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
from_step: 0
to_step: ${{ steps.determine_quest.outputs.to_step }}
- name: Rewrite badge links in README.md to relative paths
run: |
OWNER_REPO="${GITHUB_REPOSITORY}"
# Ensure relative issue links like ](/issues/new?...) remain unchanged
sed -i 's|](https://github.com/'"${OWNER_REPO}"'/issues/new?|](/issues/new?|g' README.md
# Remove any malformed absolute links that include blob/main in the path
sed -i "s#github.com/${OWNER_REPO}/blob/main/issues/new?#/issues/new?#g" README.md
- name: Comment on issue
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const quest = process.env['DETERMINE_QUEST_OUTPUTS_QUEST'] || '${{ steps.determine_quest.outputs.quest }}';
let message = '';
const readmeUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/main/README.md`;
if (quest === '0') {
message = "I couldn't determine which quest you selected. Please try again with one of the quests listed in the README.";
} else {
message = `Thanks for selecting this quest! The repository has been updated to guide you through this path. You can close this issue and continue with the instructions in the [README](${readmeUrl}).`;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
if (quest !== '0') {
github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
});
}
reset_quest:
name: Handle reset quest
needs: get_current_step
if: >-
${{ github.event_name == 'issues' &&
contains(join(github.event.issue.labels.*.name, ' '), 'reset') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Reset to step 0
uses: skills/action-update-step@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
from_step: ${{ needs.get_current_step.outputs.current_step }}
to_step: 0
- name: Rewrite badge links in README.md to relative paths
run: |
OWNER_REPO="${GITHUB_REPOSITORY}"
# Ensure relative issue links like ](/issues/new?...) remain unchanged
sed -i 's|](https://github.com/'"${OWNER_REPO}"'/issues/new?|](/issues/new?|g' README.md
# Remove any malformed absolute links that include blob/main in the path
sed -i "s#github.com/${OWNER_REPO}/blob/main/issues/new?#/issues/new?#g" README.md
- name: Comment and close issue
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Your quest has been reset! You can now select a new quest from the README."
});
github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
});