name: Issue Fixer on: issues: types: [opened] permissions: contents: write issues: write pull-requests: write concurrency: issue-fixer-${{ github.event.issue.number }} jobs: fix: if: github.repository == 'anomalyco/models.dev' runs-on: ubuntu-latest env: GH_TOKEN: ${{ github.token }} ISSUE_NUMBER: ${{ github.event.issue.number }} ISSUE_TITLE: ${{ github.event.issue.title }} ISSUE_BODY: ${{ github.event.issue.body }} steps: - name: Checkout code uses: actions/checkout@v4 with: ref: dev - name: Install opencode run: curl -fsSL https://opencode.ai/install | bash - name: Run issue fixer env: OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} OPENCODE_PERMISSION: '{"bash":"deny"}' run: | set -euo pipefail EVENTS_FILE="$RUNNER_TEMP/issue-fixer-events.jsonl" RESPONSE_FILE="$RUNNER_TEMP/issue-fixer-response.md" echo "RESPONSE_FILE=$RESPONSE_FILE" >> "$GITHUB_ENV" opencode run --agent issue-fixer -m opencode/glm-5.2 --format json < 0)' "$EVENTS_FILE" > "$RESPONSE_FILE"; then echo "Issue fixer did not produce a final response." >&2 exit 1 fi - name: Check changed paths if: success() run: | while IFS= read -r line; do path="${line:3}" case "$path" in models/*.toml|providers/*.toml) ;; *) exit 1 ;; esac done < <(git status --porcelain) - name: Create pull request if: success() env: BRANCH: issue-${{ github.event.issue.number }} run: | set -euo pipefail if [ -z "$(git status --porcelain)" ]; then if [ -s "$RESPONSE_FILE" ]; then gh issue comment "$ISSUE_NUMBER" --body-file "$RESPONSE_FILE" fi exit 0 fi git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git switch -c "$BRANCH" git add -A TITLE="fix: ${ISSUE_TITLE:0:200}" git commit -m "$TITLE" git push origin "$BRANCH" PR_BODY="$RUNNER_TEMP/issue-fixer-pr-body.md" { cat "$RESPONSE_FILE" echo echo "Closes #$ISSUE_NUMBER" echo echo "Automated by the issue fixer: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" } > "$PR_BODY" gh pr create --base dev --head "$BRANCH" --title "$TITLE" --body-file "$PR_BODY"