0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

codex-actionでバグissueを自動で修正する

Posted at

codex-actionでバグのissueを自動で修正するワークフローを作成しました。
以下がソースコードです。

name: code autofix
on:
  issues:
    types: [labeled]
jobs:
  codex:
    if: github.event.label.name == 'bug'
    runs-on: ubuntu-latest
    permissions:
      contents: write
      issues: read
      pull-requests: write
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v5
        with:
          fetch-depth: 0
      - name: Run Codex
        uses: openai/codex-action@v1
        id: codex
        with:
          openai-api-key: ${{ secrets.OPENAI_API_KEY }}
          prompt: |
            Issueの内容からバグを修正して下さい。

            Issue Content:

            ${{ github.event.issue.body }}

      - name: Setup Git
        run: |
          git config --global user.name "github-actions[bot]"
          git config --global user.email "github-actions[bot]@users.noreply.github.com"

      - name: Create branch and commit changes
        env:
          BRANCH_NAME: codex/auto-fix-${{ github.run_number }}
        run: |
          git checkout -b $BRANCH_NAME
          git add .
          git commit -m "Fix: Auto-fix by Codex for issue #${{ github.event.issue.number }}" || echo "No changes to commit"
          git push origin $BRANCH_NAME

      - name: create pull request
        uses: actions/github-script@v7
        with:
          github-token: ${{ secrets.GH_TOKEN }}
          script: |
            await github.rest.pulls.create({
              owner: context.repo.owner,
              repo: context.repo.repo,
              title: "auto fix codex",
              head: `codex/auto-fix-${{ github.run_number }}`,
              base: "main",
              body: "Codexにより自動で修正されました。",
              draft: true
            });
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?