完成管理端获取学生列表 #18
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: Node.js Package Release | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 'admin/package.json' | |
jobs: | |
check_version: | |
runs-on: ubuntu-latest | |
outputs: | |
version_changed: ${{ steps.check_version.outputs.version_changed }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: 20 | |
- name: Get previous version | |
id: previous_version | |
run: | | |
if [ -f ./admin/package.json ]; then | |
echo "PREVIOUS_VERSION=$(jq -r .version ./admin/package.json)" >> $GITHUB_ENV | |
else | |
echo "PREVIOUS_VERSION=0.0.0" >> $GITHUB_ENV | |
fi | |
- name: Check for version change | |
id: check_version | |
run: | | |
CURRENT_VERSION=$(jq -r .version ./admin/package.json) | |
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then | |
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION" | |
echo "version_changed=true" >> $GITHUB_ENV | |
else | |
echo "No version change detected." | |
echo "version_changed=false" >> $GITHUB_ENV | |
fi | |
- name: Set output for version change | |
id: set_output | |
run: echo "::set-output name=version_changed::${{ env.version_changed }}" | |
build: | |
needs: check_version | |
if: needs.check_version.outputs.version_changed == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
run: npm install | |
working-directory: ./admin | |
publish: | |
needs: build | |
if: needs.check_version.outputs.version_changed == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: 20 | |
- name: Configure npm for npm registry | |
run: | | |
echo "@pleasure1234:registry=https://registry.npmjs.org/" > .npmrc | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc | |
working-directory: ./admin | |
- name: Publish to npm | |
run: npm publish | |
working-directory: ./admin | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Configure npm for GitHub Packages | |
run: | | |
echo "@Pleasurecruise:registry=https://npm.pkg.github.com/" > .npmrc | |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GH_TOKEN }}" >> .npmrc | |
working-directory: ./admin | |
- name: Publish to GitHub Packages | |
run: npm publish --registry=https://npm.pkg.github.com/ | |
working-directory: ./admin | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GH_TOKEN }} |