From d2befe02bbc09252c251006ef702e94af9dcd84d Mon Sep 17 00:00:00 2001 From: Mobsuccess Bot Date: Tue, 1 Oct 2024 09:51:38 +0000 Subject: [PATCH] chore(gha): update npm.yml GitHub workflow --- .github/workflows/npm.yml | 76 ++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 47f5c53..34a618b 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -17,25 +17,51 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 1 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: mobsuccess-devops/github-actions-packagejsonlint@master + sortpackagejson: + name: Sort Package Json + runs-on: ubuntu-20.04 + timeout-minutes: 7 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20.12.0 + - name: Cache Node Modules + id: cache + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + path: ./node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-20.12.0 + - run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.MS_READ_PACKAGES_GITHUB_PAT }}" >> ~/.npmrc + name: Configure Credentials For GitHub Packages + - run: npm ci + if: steps.cache.outputs.cache-hit != 'true' + working-directory: . + - run: | + echo "💡 👉 Check not passing? see the doc at https://www.notion.so/mobsuccess/sort-package-json-de5cf4648e8545dbb5a2a5a910380535" + npx --yes sort-package-json@2.4.1 --check + working-directory: . prettier: name: Prettier runs-on: ubuntu-20.04 timeout-minutes: 7 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 16.16.0 + node-version: 20.12.0 - name: Cache Node Modules id: cache - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-node-modules with: path: ./node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-16.16.0 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-20.12.0 - run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.MS_READ_PACKAGES_GITHUB_PAT }}" >> ~/.npmrc name: Configure Credentials For GitHub Packages - run: npm ci @@ -48,18 +74,18 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 7 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 16.16.0 + node-version: 20.12.0 - name: Cache Node Modules id: cache - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-node-modules with: path: ./node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-16.16.0 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-20.12.0 - run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.MS_READ_PACKAGES_GITHUB_PAT }}" >> ~/.npmrc name: Configure Credentials For GitHub Packages - run: npm ci @@ -72,18 +98,18 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 7 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 16.16.0 + node-version: 20.12.0 - name: Cache Node Modules id: cache - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-node-modules with: path: ./node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-16.16.0 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-20.12.0 - run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.MS_READ_PACKAGES_GITHUB_PAT }}" >> ~/.npmrc name: Configure Credentials For GitHub Packages - run: npm ci @@ -92,7 +118,7 @@ jobs: - run: npm run test working-directory: . postBuild: - needs: [packagejsonlint, prettier, eslint, test] + needs: [packagejsonlint, sortpackagejson, prettier, eslint, test] name: Post-Build runs-on: ubuntu-20.04 timeout-minutes: 2 @@ -134,18 +160,18 @@ jobs: packageVersion: ${{ steps.outputPackageVersion.outputs.packageVersion }} if: needs.postBuild.outputs.needsPackage == 'true' steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 16.16.0 + node-version: 20.12.0 - name: Cache Node Modules id: cache - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-node-modules with: path: ./node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-16.16.0 + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}-node-20.12.0 - run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.MS_READ_PACKAGES_GITHUB_PAT }}" >> ~/.npmrc name: Configure Credentials For GitHub Packages - run: npm ci @@ -200,14 +226,14 @@ jobs: timeout-minutes: 2 if: needs.postBuild.outputs.needsPackage == 'true' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Upload uses: actions/download-artifact@v2 with: name: package - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - node-version: 16.16.0 + node-version: 20.12.0 registry-url: https://npm.pkg.github.com/ scope: "@mobsuccess-devops" - run: echo "registry=https://npm.pkg.github.com/@mobsuccess-devops" >> .npmrc