-
Notifications
You must be signed in to change notification settings - Fork 2k
Actions: Fix dominates() false positive in reusable workflows #21986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: fix | ||
| --- | ||
| * GitHub Actions support for reusable workflows was improved. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| COMMIT_SHA: | ||
| type: string | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ inputs.COMMIT_SHA }} | ||
| - run: | | ||
| npm install | ||
| npm run lint | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| on: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| is-collaborator: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get User Permission | ||
| id: checkAccess | ||
| uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b | ||
| with: | ||
| require: write | ||
| username: ${{ github.actor }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check User Permission | ||
| if: steps.checkAccess.outputs.require-result == 'false' | ||
| run: | | ||
| echo "${{ github.actor }} does not have permissions on this repo." | ||
| echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
| exit 1 | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| #needs: is-collaborator Mistake, doesn't wait for the collaborator - no security check | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} # should alert | ||
| fetch-depth: 2 | ||
| - run: yarn test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| on: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| is-collaborator: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get User Permission | ||
| id: checkAccess | ||
| uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b | ||
| with: | ||
| require: write | ||
| username: ${{ github.actor }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check User Permission | ||
| if: steps.checkAccess.outputs.require-result == 'false' | ||
| run: | | ||
| echo "${{ github.actor }} does not have permissions on this repo." | ||
| echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
| exit 1 | ||
| build: | ||
| needs: is-collaborator | ||
| uses: TestOrg/TestRepo/.github/workflows/build.yml@main | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we also add a regression for the mixed-caller case? Something like this protected caller plus another job in the same triggering workflow that calls the same reusable workflow without That seems to be the tricky case here, because otherwise the reusable workflow node can look protected just because one of its callers is protected. |
||
| with: | ||
| COMMIT_SHA: ${{ github.event.pull_request.head.sha }} # shouldn't alert since permission check | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| on: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| is-collaborator: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get User Permission | ||
| id: checkAccess | ||
| uses: actions-cool/check-user-permission@cd622002ff25c2311d2e7fb82107c0d24be83f9b | ||
| with: | ||
| require: write | ||
| username: ${{ github.actor }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Check User Permission | ||
| if: steps.checkAccess.outputs.require-result == 'false' | ||
| run: | | ||
| echo "${{ github.actor }} does not have permissions on this repo." | ||
| echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}" | ||
| exit 1 | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| needs: is-collaborator | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} # shouldn't alert since permission check | ||
| fetch-depth: 2 | ||
| - run: yarn test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe we could make this a little tighter? This sounds like a general reusable-workflow support improvement, while the change is more specifically about recognizing control checks around jobs that call reusable workflows.
Maybe something like: