Add cleanup script #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main Build Workflow | |
on: | |
pull_request_target: | |
types: [opened, synchronize, reopened] | |
push: | |
branches: | |
- 'main' | |
- 'qa' | |
tags: | |
- v** | |
jobs: | |
docs: | |
name: Create documentation | |
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags/v') | |
uses: ./.github/workflows/build-docs.yml | |
with: | |
cache_sha: ${{ format('{0}-{1}', github.ref_name, github.event.pull_request.head.sha || github.sha) }} | |
build: | |
name: Build the project | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.ref || github.ref_name }} | |
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '22.5.1' | |
cache: 'npm' | |
- name: Try to restore node_modules folder from cache | |
id: cache-node-modules | |
uses: actions/cache@v4 | |
with: | |
path: ./node_modules | |
key: npm-${{ hashFiles('./package-lock.json') }} | |
- name: Otherwise install npm dependencies | |
if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Update package.json version if necessary | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then | |
npm version --allow-same-version --no-git-tag-version $TAG_VERSION | |
echo "::warning::Tag version ($TAG_VERSION) did not match package.json version ($PACKAGE_VERSION). Updated package.json to $TAG_VERSION." | |
else | |
echo "::info::Tag version ($TAG_VERSION) matches package.json version ($PACKAGE_VERSION)." | |
fi | |
- name: Build the files! | |
run: npm run build | |
env: | |
NODE_OPTIONS: '--max-old-space-size=8192' | |
- name: Cache dist files | |
uses: actions/cache@v4 | |
with: | |
path: dist | |
key: dist-${{ format('{0}-{1}', github.ref_name, github.event.pull_request.head.sha || github.sha) }} | |
deploy-pages: | |
needs: [docs, build] | |
if: ${{ always() && needs.build.result == 'success' }} | |
name: Deploy the files | |
uses: ./.github/workflows/deploy.yml | |
with: | |
cache_sha: ${{ format('{0}-{1}', github.ref_name, github.event.pull_request.head.sha || github.sha) }} | |
secrets: inherit |