Skip to content

Commit 67ce3f9

Browse files
committed
fix: correct environment variable setup and PowerShell syntax
- Use GITHUB_ENV instead of GITHUB_OUTPUT for setting env vars - Change %VAR% to :VAR for PowerShell compatibility - Fix PR_NUMBER to use pr_number output in ai-implement.yml
1 parent 863f9cc commit 67ce3f9

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

.github/workflows/ai-implement.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ jobs:
4646
4747
- name: Set environment variables
4848
run: |
49-
echo ISSUE_NUM=${{ steps.extract.outputs.issue_number }} >> %GITHUB_OUTPUT%
50-
echo PR_NUMBER=${{ steps.extract.outputs.issue_number }} >> %GITHUB_OUTPUT%
49+
echo "ISSUE_NUM=${{ steps.extract.outputs.issue_number }}" >> $env:GITHUB_ENV
50+
echo "PR_NUMBER=${{ steps.extract.outputs.issue_number }}" >> $env:GITHUB_ENV
5151
5252
- name: Get issue and plan
5353
id: issue
@@ -106,8 +106,8 @@ jobs:
106106
git config user.name "AI Agent"
107107
git config user.email "ai@github.local"
108108
git add -A
109-
git commit -m "AI: Implement issue-%ISSUE_NUM%" 2>nul || exit 0
110-
git push origin "ai/issue-%ISSUE_NUM%" 2>nul || exit 0
109+
git commit -m "AI: Implement issue-$env:ISSUE_NUM" 2>nul || exit 0
110+
git push origin "ai/issue-$env:ISSUE_NUM" 2>nul || exit 0
111111
112112
- name: Build
113113
run: |
@@ -133,7 +133,7 @@ jobs:
133133
node -e "
134134
const fs = require('fs');
135135
let p = fs.readFileSync('.github/workflows/prompts/ai-fix-tests-prompt.txt','utf8');
136-
p = p.replace(/{{issue_number}}/g, '%ISSUE_NUM%');
136+
p = p.replace(/{{issue_number}}/g, '$env:ISSUE_NUM');
137137
fs.writeFileSync('fix_prompt.txt', p);
138138
"
139139
@@ -149,23 +149,23 @@ jobs:
149149
git config user.name "AI Agent"
150150
git config user.email "ai@github.local"
151151
git add -A
152-
git commit -m "AI: Fix tests issue-%ISSUE_NUM%" 2>nul || exit 0
153-
git push origin "ai/issue-%ISSUE_NUM%" 2>nul || exit 0
152+
git commit -m "AI: Fix tests issue-$env:ISSUE_NUM" 2>nul || exit 0
153+
git push origin "ai/issue-$env:ISSUE_NUM" 2>nul || exit 0
154154
155155
- name: Create PR
156156
if: always()
157157
env:
158158
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159159
run: |
160-
gh pr create --base main --head "ai/issue-%ISSUE_NUM%" --title "AI: Issue #%ISSUE_NUM%" --body "AI implementation" 2>nul || echo PR exists
160+
gh pr create --base main --head "ai/issue-$env:ISSUE_NUM" --title "AI: Issue #$env:ISSUE_NUM" --body "AI implementation" 2>nul || echo PR exists
161161
162162
- name: Mark issue as done
163163
if: always()
164164
uses: actions/github-script@v7
165165
with:
166166
script: |
167167
await github.rest.issues.addLabels({
168-
issue_number: parseInt('%ISSUE_NUM%'),
168+
issue_number: parseInt('$env:ISSUE_NUM'),
169169
owner: context.repo.owner,
170170
repo: context.repo.repo,
171171
labels: ['ai-done']

.github/workflows/ai-iterate.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ jobs:
4747
4848
- name: Set environment variables
4949
run: |
50-
echo ISSUE_NUM=${{ steps.extract.outputs.issue_number }} >> %GITHUB_OUTPUT%
51-
echo PR_NUMBER=${{ steps.extract.outputs.pr_number }} >> %GITHUB_OUTPUT%
50+
echo "ISSUE_NUM=${{ steps.extract.outputs.issue_number }}" >> $env:GITHUB_ENV
51+
echo "PR_NUMBER=${{ steps.extract.outputs.pr_number }}" >> $env:GITHUB_ENV
5252
5353
- name: Get PR comments
5454
id: comments
@@ -81,7 +81,7 @@ jobs:
8181
# 替换配置文件中的占位符
8282
powershell -Command "$content = Get-Content '.github/workflows/oh-my-opencode.json' -Raw; $content = $content -replace 'MINIMAX_API_KEY', $env:MINIMAX_API_KEY; Set-Content -Path $env:USERPROFILE\\.config\\opencode\\oh-my-opencode.json -Value $content"
8383
84-
node -e "const fs=require('fs');const c=JSON.parse(process.env.COMMENTS_DATA);let p=fs.readFileSync('.github/workflows/prompts/ai-iterate-prompt.txt','utf8');p=p.replace(/{{issue_number}}/g,'%ISSUE_NUM%').replace(/{{pr_number}}/g,'%PR_NUMBER%').replace(/{{comments}}/g,c.join('\n\n'));fs.writeFileSync('prompt.txt',p);"
84+
node -e "const fs=require('fs');const c=JSON.parse(process.env.COMMENTS_DATA);let p=fs.readFileSync('.github/workflows/prompts/ai-iterate-prompt.txt','utf8');p=p.replace(/{{issue_number}}/g,'$env:ISSUE_NUM').replace(/{{pr_number}}/g,'$env:PR_NUMBER').replace(/{{comments}}/g,c.join('\n\n'));fs.writeFileSync('prompt.txt',p);"
8585
8686
opencode . < prompt.txt --opencode-go=yes
8787
@@ -100,7 +100,7 @@ jobs:
100100
git config user.email "ai@github.local"
101101
git add -A
102102
git commit -m "AI: Iterate based on feedback" 2>nul
103-
git push origin "ai/issue-%ISSUE_NUM%" 2>nul
103+
git push origin "ai/issue-$env:ISSUE_NUM" 2>nul
104104
105105
- name: Post iteration report
106106
if: steps.changes.outputs.changed > 0

0 commit comments

Comments
 (0)