Skip to content

Update dependency eslint-plugin-jest to v29.11.4 (#3058) #11643

Update dependency eslint-plugin-jest to v29.11.4 (#3058)

Update dependency eslint-plugin-jest to v29.11.4 (#3058) #11643

Workflow file for this run

name: build
on:
push:
branches:
- main
pull_request: { }
defaults:
run:
shell: bash
jobs:
build:
if: ${{
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|| (github.event_name == 'push' && !startsWith(github.event.head_commit.message, '[push-back]'))
|| github.event_name != 'push'
}}
concurrency:
group: build-${{github.ref}}
cancel-in-progress: true
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{secrets.PUSH_BACK_TOKEN}}
submodules: recursive
lfs: true
fetch-depth: 1
- name: Read action's Node.js version
id: read-node-version
run: |
USING=$( yq '.runs.using' ./action.yml )
if ! [[ "$USING" =~ ^node[0-9]+$ ]]; then
echo "::error::action.yml: .runs.using doesn't start with 'node': '$USING'"
exit 1
fi
VERSION=${USING:4}
echo "Action's Node.js version: $VERSION"
echo "result=$VERSION" | tee -a $GITHUB_OUTPUT
- name: Setup Node.js ${{steps.read-node-version.outputs.result}}
uses: actions/setup-node@v6
with:
node-version: '${{steps.read-node-version.outputs.result}}'
- name: Update Node.js version in project files
run: |
node update-node-version-in-files "${{steps.read-node-version.outputs.result}}"
- name: Get package manager
id: package-manager
run: |
PACKAGE_MANAGER=$( yq -r '.packageManager' ./package.json )
PACKAGE_MANAGER=${PACKAGE_MANAGER%%@*}
if ! [[ "$PACKAGE_MANAGER" =~ ^[a-z]+$ ]]; then
echo "::error::package.json: unsupported .packageManager format: '$PACKAGE_MANAGER'"
exit 1
fi
echo "PACKAGE_MANAGER=$PACKAGE_MANAGER" | tee -a $GITHUB_ENV
echo "result=$PACKAGE_MANAGER" | tee -a $GITHUB_OUTPUT
PACKAGE_MANAGER_NAME=${PACKAGE_MANAGER^}
echo "name=$PACKAGE_MANAGER_NAME" | tee -a $GITHUB_OUTPUT
- name: Create cache params
id: cache-params
run: |
echo "key=${{runner.os}}-dependencies-${{steps.read-node-version.outputs.result}}-${{hashFiles('package.json', 'pnpm-*.yml', '.yarnrc.yml', 'yarn.lock' , '.pnp.*', '.yarn/patches/**', '.yarn/plugins/**', '.yarn/releases/**', '.yarn/versions/**')}}" | tee -a $GITHUB_OUTPUT
echo "paths<<EOF" | tee -a $GITHUB_OUTPUT
echo "node_modules" | tee -a $GITHUB_OUTPUT
echo ".yarn/cache" | tee -a $GITHUB_OUTPUT
echo "EOF" | tee -a $GITHUB_OUTPUT
- name: Restore dependencies cache
id: restore-dependencies-cache
uses: actions/cache/restore@v5
with:
key: ${{steps.cache-params.outputs.key}}
path: ${{steps.cache-params.outputs.paths}}
- name: Install dependencies
run: |
if [ "${{steps.package-manager.outputs.result}}" == "pnpm" ]; then
pnpm install --no-frozen-lockfile
elif [ "${{steps.package-manager.outputs.result}}" == "yarn" ]; then
yarn install --no-immutable
else
echo "::error::Unsupported package manager: $PACKAGE_MANAGER"
exit 1
fi
- name: Save dependencies cache
if: ${{steps.restore-dependencies-cache.outputs.cache-hit != 'true'}}
uses: actions/cache/save@v5
with:
key: ${{steps.cache-params.outputs.key}}
path: ${{steps.cache-params.outputs.paths}}
- name: Build
run: |
${{steps.package-manager.outputs.result}} run build
- name: Upload dist to artifacts
if: ${{always()}}
uses: actions/upload-artifact@v6
with:
name: dist
path: dist/
if-no-files-found: error
overwrite: true
retention-days: 30
# $$$sync-with-template-modifiable: validation $$$
- name: Run current action
id: current
uses: ./
with:
dryRun: 'true'
githubToken: ${{github.token}}
# $$$sync-with-template-modifiable-end$$$
- name: Push back
if: ${{github.event_name == 'push' && startsWith(github.ref, 'refs/heads/')}}
uses: remal-github-actions/push-back@v2
with:
message: '[push-back] Push-back updated files during build'
- name: Read version
id: readVersion
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
uses: remal-github-actions/read-nodejs-package-version@v1
- name: Remove files listed in .releaseignore
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
id: releaseignore
uses: actions/github-script@v8
with:
script: |
const fs = require('fs')
const path = require('path')
const cwdPath = path.resolve(process.cwd())
const releaseIgnorePath = '.releaseignore'
const releaseIgnoreFullPath = path.resolve(cwdPath, releaseIgnorePath)
if (!fs.existsSync(releaseIgnoreFullPath)) {
core.info(`${releaseIgnorePath} file does not exist, skipping removal of files.`)
core.setOutput('skipped', 'true')
return
}
let patternsToIgnore = fs.readFileSync(releaseIgnoreFullPath, 'utf-8')
.split('\n')
.map(line => line.replace(/#.*/, '').trim())
.filter(line => line.length)
.join('\n')
if (!patternsToIgnore.length) {
core.info(`${releaseIgnorePath} file does not have patterns, skipping removal of files.`)
core.setOutput('skipped', 'true')
return
}
const gitDirPath = path.resolve(cwdPath, '.git')
const globber = await glob.create(patternsToIgnore)
const files = await globber.glob()
files
.map(file => path.resolve(cwdPath, file))
.filter(file => file != cwdPath)
.filter(file => file != gitDirPath && !file.startsWith(gitDirPath + path.sep))
.forEach(file => {
core.debug(`Removing: ${file}`)
fs.rmSync(file, { recursive: true, force: true })
})
- name: Prepare release commit
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main' && !steps.releaseignore.outputs.skipped}}
run: |
RELEASE_BRANCH="release/v${{steps.readVersion.outputs.majorVersion}}"
git switch --force-create "$RELEASE_BRANCH"
git add --all
git commit -m "[skip-ci] Release v${{steps.readVersion.outputs.majorVersion}}" || true
git push --force origin "$RELEASE_BRANCH"
- name: Create tag
if: ${{github.event_name == 'push' && github.ref == 'refs/heads/main'}}
uses: remal-github-actions/create-tag@v2
with:
tagName: 'v${{steps.readVersion.outputs.majorVersion}}'