feat: add label management to Sisyphus workflow (#215)

- Add 'sisyphus: working' label when Sisyphus starts working on an issue/PR
- Remove label when work completes (success or failure)
- Label operations use gh CLI with idempotent commands
- Handles both issues and PRs with proper conditional logic
- Uses || true for error handling to prevent workflow failures

Closes #202

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
Sisyphus
2025-12-25 15:37:48 +09:00
committed by GitHub
parent 8d9b68d84b
commit 2bad1b5c95

View File

@@ -243,6 +243,27 @@ jobs:
gh api "/repos/${{ github.repository }}/issues/comments/${{ steps.context.outputs.comment_id }}/reactions" \
-X POST -f content="eyes" || true
- name: Add working label
if: steps.context.outputs.number != ''
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
run: |
gh label create "sisyphus: working" \
--repo "${{ github.repository }}" \
--color "fcf2e1" \
--description "Sisyphus is currently working on this" \
--force || true
if [[ "${{ steps.context.outputs.type }}" == "pr" ]]; then
gh pr edit "${{ steps.context.outputs.number }}" \
--repo "${{ github.repository }}" \
--add-label "sisyphus: working" || true
else
gh issue edit "${{ steps.context.outputs.number }}" \
--repo "${{ github.repository }}" \
--add-label "sisyphus: working" || true
fi
- name: Run OpenCode
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
@@ -286,19 +307,30 @@ jobs:
git push origin "$BRANCH" || true
fi
# Remove :eyes:, add :+1:
- name: Update reaction
if: always() && steps.context.outputs.comment_id != ''
- name: Update reaction and remove label
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
run: |
# Remove eyes
REACTION_ID=$(gh api "/repos/${{ github.repository }}/issues/comments/${{ steps.context.outputs.comment_id }}/reactions" \
--jq '.[] | select(.content == "eyes" and .user.login == "sisyphus-dev-ai") | .id' | head -1)
if [[ -n "$REACTION_ID" ]]; then
gh api -X DELETE "/repos/${{ github.repository }}/reactions/${REACTION_ID}" || true
if [[ -n "${{ steps.context.outputs.comment_id }}" ]]; then
REACTION_ID=$(gh api "/repos/${{ github.repository }}/issues/comments/${{ steps.context.outputs.comment_id }}/reactions" \
--jq '.[] | select(.content == "eyes" and .user.login == "sisyphus-dev-ai") | .id' | head -1)
if [[ -n "$REACTION_ID" ]]; then
gh api -X DELETE "/repos/${{ github.repository }}/reactions/${REACTION_ID}" || true
fi
gh api "/repos/${{ github.repository }}/issues/comments/${{ steps.context.outputs.comment_id }}/reactions" \
-X POST -f content="+1" || true
fi
# Add thumbs up
gh api "/repos/${{ github.repository }}/issues/comments/${{ steps.context.outputs.comment_id }}/reactions" \
-X POST -f content="+1" || true
if [[ -n "${{ steps.context.outputs.number }}" ]]; then
if [[ "${{ steps.context.outputs.type }}" == "pr" ]]; then
gh pr edit "${{ steps.context.outputs.number }}" \
--repo "${{ github.repository }}" \
--remove-label "sisyphus: working" || true
else
gh issue edit "${{ steps.context.outputs.number }}" \
--repo "${{ github.repository }}" \
--remove-label "sisyphus: working" || true
fi
fi