mirror of
https://github.com/renovatebot/github-action.git
synced 2025-12-16 08:52:35 +00:00
ci: simplify (#883)
This commit is contained in:
parent
4c22a107ea
commit
a0608873fb
4 changed files with 90 additions and 44 deletions
60
.github/actions/setup-node/action.yml
vendored
Normal file
60
.github/actions/setup-node/action.yml
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
name: 'Setup Node.js'
|
||||||
|
description: 'Setup Node and install dependencies using cache'
|
||||||
|
inputs:
|
||||||
|
save-cache:
|
||||||
|
description: 'Save cache when needed'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: ⚙️ Calculate `CACHE_KEY`
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo 'CACHE_KEY=node_modules-${{
|
||||||
|
hashFiles('.node-version', 'pnpm-lock.yaml')
|
||||||
|
}}' >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: ♻️ Restore `node_modules`
|
||||||
|
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
||||||
|
id: node-modules-restore
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ env.CACHE_KEY }}
|
||||||
|
enableCrossOsArchive: true
|
||||||
|
|
||||||
|
- name: Calculate `CACHE_HIT`
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo 'CACHE_HIT=${{
|
||||||
|
(steps.node-modules-restore.outputs.cache-hit == 'true') && 'true' || ''
|
||||||
|
}}' >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: ⚙️ Setup pnpm
|
||||||
|
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
|
||||||
|
with:
|
||||||
|
standalone: true
|
||||||
|
|
||||||
|
- name: ⚙️ Setup Node.js ${{ inputs.node-version }}
|
||||||
|
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||||
|
with:
|
||||||
|
node-version-file: .node-version
|
||||||
|
cache: ${{ env.CACHE_HIT != 'true' && 'pnpm' || '' }}
|
||||||
|
|
||||||
|
- name: 📥 Install dependencies
|
||||||
|
if: env.CACHE_HIT != 'true'
|
||||||
|
shell: bash
|
||||||
|
run: pnpm install --frozen-lockfile
|
||||||
|
env:
|
||||||
|
# Other environment variables
|
||||||
|
HUSKY: '0' # By default do not run HUSKY install
|
||||||
|
|
||||||
|
- name: ♻️ Write `node_modules` cache
|
||||||
|
if: inputs.save-cache == 'true' && env.CACHE_HIT != 'true'
|
||||||
|
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ env.CACHE_KEY }}
|
||||||
|
enableCrossOsArchive: true
|
||||||
71
.github/workflows/build.yml
vendored
71
.github/workflows/build.yml
vendored
|
|
@ -10,10 +10,23 @@ concurrency:
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
NODE_VERSION: 20
|
|
||||||
RENOVATE_VERSION: 38.142.7 # renovate: datasource=docker depName=renovate packageName=ghcr.io/renovatebot/renovate
|
RENOVATE_VERSION: 38.142.7 # renovate: datasource=docker depName=renovate packageName=ghcr.io/renovatebot/renovate
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
prepare:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
with:
|
||||||
|
show-progress: false
|
||||||
|
|
||||||
|
- name: 📥 Setup Node.js
|
||||||
|
uses: ./.github/actions/setup-node
|
||||||
|
with:
|
||||||
|
save-cache: true
|
||||||
|
|
||||||
commitlint:
|
commitlint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }}
|
if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }}
|
||||||
|
|
@ -31,6 +44,8 @@ jobs:
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }}
|
if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }}
|
||||||
|
|
||||||
|
|
@ -40,24 +55,15 @@ jobs:
|
||||||
with:
|
with:
|
||||||
show-progress: false
|
show-progress: false
|
||||||
|
|
||||||
- name: enable corepack
|
- name: 📥 Setup Node.js
|
||||||
run: corepack enable
|
uses: ./.github/actions/setup-node
|
||||||
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
cache: pnpm
|
|
||||||
|
|
||||||
- name: enable corepack
|
|
||||||
run: corepack enable
|
|
||||||
|
|
||||||
- name: Install project
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: pnpm lint
|
run: pnpm lint
|
||||||
|
|
||||||
e2e:
|
e2e:
|
||||||
|
needs:
|
||||||
|
- prepare
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }}
|
if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login }}
|
||||||
|
|
||||||
|
|
@ -73,20 +79,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
show-progress: false
|
show-progress: false
|
||||||
|
|
||||||
- name: enable corepack
|
- name: 📥 Setup Node.js
|
||||||
run: corepack enable
|
uses: ./.github/actions/setup-node
|
||||||
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
cache: pnpm
|
|
||||||
|
|
||||||
- name: enable corepack
|
|
||||||
run: corepack enable
|
|
||||||
|
|
||||||
- name: Install project
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
|
|
@ -121,7 +115,10 @@ jobs:
|
||||||
docker-user: root
|
docker-user: root
|
||||||
|
|
||||||
release:
|
release:
|
||||||
needs: [lint, commitlint, e2e]
|
needs:
|
||||||
|
- lint
|
||||||
|
- commitlint
|
||||||
|
- e2e
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Git user
|
- name: Setup Git user
|
||||||
|
|
@ -150,20 +147,8 @@ jobs:
|
||||||
git merge --no-ff -Xtheirs -m 'skip: merge (${{ github.sha }}) [skip release]' ${{ github.sha }}
|
git merge --no-ff -Xtheirs -m 'skip: merge (${{ github.sha }}) [skip release]' ${{ github.sha }}
|
||||||
commit=$(git rev-parse HEAD)
|
commit=$(git rev-parse HEAD)
|
||||||
|
|
||||||
- name: enable corepack
|
- name: 📥 Setup Node.js
|
||||||
run: corepack enable
|
uses: ./.github/actions/setup-node
|
||||||
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
cache: pnpm
|
|
||||||
|
|
||||||
- name: enable corepack
|
|
||||||
run: corepack enable
|
|
||||||
|
|
||||||
- name: Install project
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
|
|
||||||
- name: Push release branch
|
- name: Push release branch
|
||||||
run: git push origin release:release
|
run: git push origin release:release
|
||||||
|
|
|
||||||
1
.node-version
Normal file
1
.node-version
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
20.18.0
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.12.3",
|
"packageManager": "pnpm@9.12.3",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.9.0",
|
"node": "^20.9.0 || ^22.11.0",
|
||||||
"pnpm": "^9.0.0"
|
"pnpm": "^9.0.0"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue