Conversation
| if: inputs.test_deploy == true && inputs.test_app_name != '' | ||
| needs: build-and-push-test-branch | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout test branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ inputs.test_branch_name }} | ||
|
|
||
| - name: Create test package | ||
| run: | | ||
| mkdir -p test-app | ||
| cat > test-app/index.html << EOF | ||
| <html> | ||
| <body> | ||
| <h1>Test Deployment</h1> | ||
| <p>Version: ${{ inputs.tag_name }}</p> | ||
| <p>Branch: ${{ inputs.test_branch_name }}</p> | ||
| <p>Time: $(date)</p> | ||
| </body> | ||
| </html> | ||
| EOF | ||
|
|
||
| - name: Test deploy to Azure Web App | ||
| uses: ./ | ||
| with: | ||
| app-name: ${{ inputs.test_app_name }} | ||
| package: test-app | ||
|
|
||
| - name: Test deployment result | ||
| run: | | ||
| echo "## 🚀 Test Deployment Successful" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "✅ Deployed to: **${{ inputs.test_app_name }}**" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "🔗 Verify at: https://${{ inputs.test_app_name }}.azurewebsites.net" >> $GITHUB_STEP_SUMMARY |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, to fix this class of problem you should add an explicit permissions block at the workflow or job level that grants only the minimal scopes required. Jobs that only need to read code (for checkout) can typically use contents: read. Jobs that need to push commits or create tags require contents: write, and more specialized operations (e.g., interacting with issues or PRs) should use the corresponding fine-grained permissions.
For this specific workflow, the build-and-push-test-branch job already has permissions: contents: write, which is appropriate because it commits and pushes a branch. The flagged test-deployment job, however, only checks out code and performs a deployment using a local action. There’s no evidence it needs write access to the repository itself. The best fix while preserving existing behavior is to add a permissions block to test-deployment that limits the GITHUB_TOKEN to read-only repository contents. Concretely, in .github/workflows/test-release.yml, within the test-deployment job (around line 135), add:
permissions:
contents: readjust under the job name (and before or after if: / needs: / runs-on: — order among job keys doesn’t affect semantics). No other code or imports are needed.
| @@ -136,6 +136,8 @@ | ||
| if: inputs.test_deploy == true && inputs.test_app_name != '' | ||
| needs: build-and-push-test-branch | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout test branch |
No description provided.