From 807be0a345a1e3a2d2807513a9530173379d06d9 Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Mon, 28 Nov 2022 13:35:29 -0500 Subject: [PATCH] chore: forbid non-npm lockfiles --- .github/actions/lockfiles/action.yml | 21 +++++++++++++++++++++ .github/workflows/ci.yml | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 .github/actions/lockfiles/action.yml diff --git a/.github/actions/lockfiles/action.yml b/.github/actions/lockfiles/action.yml new file mode 100644 index 000000000..116eec5b1 --- /dev/null +++ b/.github/actions/lockfiles/action.yml @@ -0,0 +1,21 @@ +name: 'Lockfile' +description: 'Forbid non-npm lockfiles' +runs: + using: composite + steps: + - name: Check lockfiles + uses: actions/github-script@v6 + with: + script: | + const {existsSync} = require('fs'); + ['yarn.lock', 'pnpm-lock.yaml'].forEach(forbiddenLockFile => { + if(existsSync(forbiddenLockFile)) { + const error = `Lockfile ${forbiddenLockFile} is not allowed in this repo, remove it.`; + core.error( + error, + {title: 'Forbidden lockfile', file: forbiddenLockFile} + ); + core.setFailed(error); + } + }); + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cac459fa..8039f2592 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,8 @@ jobs: uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3 - name: Setup uses: ./.github/actions/setup + - name: Check lockfiles + uses: ./.github/actions/lockfiles - name: Tests run: npm test - name: Build