Skip to content

fix: correct environment variable setup and PowerShell syntax - #203

Merged
ModerRAS merged 1 commit into
masterfrom
fix/env-vars-powershell
Mar 15, 2026
Merged

ModerRAS merged 1 commit into
masterfrom
fix/env-vars-powershell

Conversation

@ModerRAS

Copy link
Copy Markdown
Owner

Summary

  • 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

- 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
Copilot AI review requested due to automatic review settings March 15, 2026 16:02
@coderabbitai

coderabbitai Bot commented Mar 15, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@ModerRAS has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 1 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3f1c5b36-1050-4ee5-ba44-c9599df59af9

📥 Commits

Reviewing files that changed from the base of the PR and between 863f9cc and 67ce3f9.

📒 Files selected for processing (2)
  • .github/workflows/ai-implement.yml
  • .github/workflows/ai-iterate.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/env-vars-powershell
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude

claude Bot commented Mar 15, 2026

Copy link
Copy Markdown

Claude finished @ModerRAS's task —— View job


Code Review: PR #203 - Environment Variable and PowerShell Syntax Fixes

I've reviewed the changes in this PR that fixes environment variable setup and PowerShell syntax in GitHub Actions workflows. Here's my analysis:

Positive Changes

  1. Correct use of GITHUB_ENV vs GITHUB_OUTPUT: The PR correctly changes from %GITHUB_OUTPUT% to $env:GITHUB_ENV for setting environment variables that persist across steps. This is the proper approach for Windows runners.

  2. PowerShell variable syntax: Changing %VAR% to $env:VAR is correct for PowerShell compatibility on Windows runners.

  3. Consistent quoting: Adding quotes around environment variable values (echo "ISSUE_NUM=...") is a good practice to handle values with spaces.

⚠️ Issues Found

1. Mixed Shell Environments (Critical)

The workflows use a mix of CMD batch syntax (%VAR%) and PowerShell syntax ($env:VAR) inconsistently:

  • Lines 39-40 in both files still use %USERPROFILE% (CMD syntax) but the rest of the file uses PowerShell syntax
  • Lines 45-46, 92, 99 still use %GITHUB_OUTPUT% (CMD syntax) for outputting step results

Recommendation: Standardize on one shell type. Since the workflows use runs-on: windows-latest and most commands are PowerShell, consider:

  • Changing all CMD syntax to PowerShell
  • OR explicitly setting shell: cmd for CMD steps and shell: pwsh for PowerShell steps

2. Inconsistent PR_NUMBER Handling

In ai-implement.yml:50, PR_NUMBER is set to issue_number, but in ai-iterate.yml:51, it correctly uses pr_number. This appears intentional for different workflows but should be documented.

3. Missing Shell Declarations

GitHub Actions best practice is to explicitly declare the shell for each run step, especially when mixing shell types:

- name: Example step
  shell: pwsh
  run: |
    # PowerShell commands

4. Potential Variable Scope Issues

Environment variables set with GITHUB_ENV are available to subsequent steps, but output variables (set with GITHUB_OUTPUT) are only available to subsequent steps via steps.<step_id>.outputs.<name>. The current code mixes these approaches.

🔧 Recommended Fixes

  1. Standardize shell usage:

    - name: Copy oh-my-opencode config
      shell: cmd
      run: |
        mkdir %USERPROFILE%\.config\opencode
        copy .github\workflows\oh-my-opencode.json %USERPROFILE%\.config\opencode\oh-my-opencode.json
  2. Fix remaining CMD syntax:

    • Lines 45-46, 92, 99 in both files should use PowerShell syntax: $env:GITHUB_OUTPUT instead of %GITHUB_OUTPUT%
  3. Add explicit shell declarations for clarity.

🛡️ Security Assessment

  • Secrets handling: Appropriate use of ${{ secrets.NAME }} syntax
  • Token permissions: GITHUB_TOKEN has appropriate scopes (contents: write, pull-requests: write)
  • No obvious security vulnerabilities in the changes

📊 Test Coverage Considerations

These are infrastructure/CI changes, so:

  • Manual testing of workflow runs is needed
  • Consider adding a test workflow that validates the environment variable setup
  • The changes don't affect application code, so no unit test updates required

📝 Summary

The PR addresses important compatibility issues but introduces inconsistency in shell usage. The core fixes (GITHUB_ENV and PowerShell syntax) are correct, but the workflows need standardization.

Status: Approved with recommendations - The fixes work, but should be made consistent for maintainability.


Review Checklist:

  • Code quality and best practices reviewed
  • Potential bugs/issues identified
  • Performance considerations noted
  • Security concerns assessed
  • Test coverage considerations evaluated

@ModerRAS
ModerRAS merged commit 785c5ce into master Mar 15, 2026
4 of 5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes GitHub Actions workflow variable propagation and Windows/PowerShell-specific syntax so downstream steps can correctly consume ISSUE_NUM / PR_NUMBER.

Changes:

  • Switch env-var export to GITHUB_ENV (instead of GITHUB_OUTPUT) for step-to-step environment variables
  • Update command syntax to PowerShell-style environment variable references
  • Adjust branch naming / prompt placeholder replacement to use the new env-var approach

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
.github/workflows/ai-iterate.yml Writes ISSUE_NUM/PR_NUMBER to GITHUB_ENV and updates prompt/branch usage accordingly
.github/workflows/ai-implement.yml Writes env vars to GITHUB_ENV and updates branch/prompt/github-script usage accordingly

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +49 to +50
echo "ISSUE_NUM=${{ steps.extract.outputs.issue_number }}" >> $env:GITHUB_ENV
echo "PR_NUMBER=${{ steps.extract.outputs.issue_number }}" >> $env:GITHUB_ENV
Comment on lines +50 to +51
echo "ISSUE_NUM=${{ steps.extract.outputs.issue_number }}" >> $env:GITHUB_ENV
echo "PR_NUMBER=${{ steps.extract.outputs.pr_number }}" >> $env:GITHUB_ENV
git add -A
git commit -m "AI: Iterate based on feedback" 2>nul
git push origin "ai/issue-%ISSUE_NUM%" 2>nul
git push origin "ai/issue-$env:ISSUE_NUM" 2>nul
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"

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);"
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);"
const fs = require('fs');
let p = fs.readFileSync('.github/workflows/prompts/ai-fix-tests-prompt.txt','utf8');
p = p.replace(/{{issue_number}}/g, '%ISSUE_NUM%');
p = p.replace(/{{issue_number}}/g, '$env:ISSUE_NUM');
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --base main --head "ai/issue-%ISSUE_NUM%" --title "AI: Issue #%ISSUE_NUM%" --body "AI implementation" 2>nul || echo PR exists
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
script: |
await github.rest.issues.addLabels({
issue_number: parseInt('%ISSUE_NUM%'),
issue_number: parseInt('$env:ISSUE_NUM'),
@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR检查报告

📋 检查概览

🧪 测试结果

平台 状态 详情
Ubuntu 🔴 失败 测试结果不可用
Windows 🔴 失败 测试结果不可用

📊 代码质量

  • ✅ 代码格式化检查
  • ✅ 安全漏洞扫描
  • ✅ 依赖包分析
  • ✅ 代码覆盖率收集

📁 测试产物

  • 测试结果文件已上传为artifacts
  • 代码覆盖率已上传到Codecov

🔗 相关链接


此报告由GitHub Actions自动生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants