Update check-dist.yml

This commit is contained in:
11223344p 2024-06-28 05:04:06 +08:00 committed by GitHub
parent 08528b0d2d
commit 1ff46e0aea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,66 +1,24 @@
# In TypeScript actions, `dist/` is a special directory. When you reference - name: Setup Node.js environment
# an action with the `uses:` property, `dist/index.js` is the code that will be uses: actions/setup-node@v4.0.2
# run. For this project, the `dist/index.js` file is transpiled from other with:
# source files. This workflow ensures the `dist/` directory contains the # Set always-auth in npmrc.
# expected transpiled code. always-auth: # optional, default is false
# # Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.
# If this workflow is run from a feature branch, it will act as an additional CI node-version: # optional
# check and fail if the checked-in `dist/` directory does not match what is # File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.
# expected from the build. node-version-file: # optional
name: Check Transpiled JavaScript # Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.
architecture: # optional
on: # Set this option if you want the action to check for the latest available version that satisfies the version spec.
pull_request: check-latest: # optional
branches: # Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN.
- main registry-url: # optional
push: # Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).
branches: scope: # optional
- main # Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
token: # optional, default is ${{ github.server_url == 'https://github.com' && github.token || '' }}
permissions: # Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.
contents: read cache: # optional
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.
jobs: cache-dependency-path: # optional
check-dist:
name: Check dist/
runs-on: ubuntu-latest
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- name: Install Dependencies
id: install
run: npm ci
- name: Build dist/ Directory
id: build
run: npm run bundle
# This will fail the workflow if the PR wasn't created by Dependabot.
- name: Compare Directories
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff --ignore-space-at-eol --text dist/
exit 1
fi
# If `dist/` was different than expected, and this was not a Dependabot
# PR, upload the expected version as a workflow artifact.
- if: ${{ failure() && steps.diff.outcome == 'failure' }}
name: Upload Artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/