2021-02-05 17:03:12 +08:00
|
|
|
name: Prevent yarn.lock changes in PRs
|
2021-02-02 23:50:55 +08:00
|
|
|
on: [pull_request]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
main:
|
2021-02-05 17:03:12 +08:00
|
|
|
name: Prevent yarn.lock changes in PRs
|
2021-02-02 23:50:55 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2021-04-06 23:23:01 +08:00
|
|
|
- uses: octokit/request-action@v2.x
|
|
|
|
id: get_permissions
|
|
|
|
with:
|
|
|
|
route: GET /repos/microsoft/vscode/collaborators/{username}/permission
|
|
|
|
username: ${{ github.event.pull_request.user.login }}
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set control output variable
|
|
|
|
id: control
|
|
|
|
run: |
|
2021-04-06 23:28:00 +08:00
|
|
|
echo "user: ${{ github.event.pull_request.user.login }}"
|
2021-04-06 23:41:22 +08:00
|
|
|
echo "role: ${{ fromJson(steps.get_permissions.outputs.data).permission }}"
|
2022-06-27 02:52:40 +08:00
|
|
|
echo "is dependabot: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}"
|
2023-06-05 21:48:40 +08:00
|
|
|
echo "should_run: ${{ !contains(fromJson('["admin", "maintain", "write"]'), fromJson(steps.get_permissions.outputs.data).permission) }}"
|
|
|
|
echo "should_run=${{ !contains(fromJson('["admin", "maintain", "write"]'), fromJson(steps.get_permissions.outputs.data).permission) && github.event.pull_request.user.login != 'dependabot[bot]' }}" >> $GITHUB_OUTPUT
|
2021-04-06 23:23:01 +08:00
|
|
|
- name: Get file changes
|
2021-03-04 23:08:49 +08:00
|
|
|
uses: trilom/file-changes-action@ce38c8ce2459ca3c303415eec8cb0409857b4272
|
2024-09-06 21:18:02 +08:00
|
|
|
if: ${{ steps.control.outputs.should_run == 'true' }}
|
2023-07-11 01:19:55 +08:00
|
|
|
- name: Check for lockfile changes
|
2024-09-06 21:18:02 +08:00
|
|
|
if: ${{ steps.control.outputs.should_run == 'true' }}
|
2021-02-02 23:50:55 +08:00
|
|
|
run: |
|
2023-07-11 01:19:55 +08:00
|
|
|
cat $HOME/files.json | jq -e 'any(test("yarn\\.lock$|Cargo\\.lock$")) | not' \
|
|
|
|
|| (echo "Changes to yarn.lock/Cargo.lock files aren't allowed in PRs." && exit 1)
|