Skip to content

Commit

Permalink
[ci/cd] 自动部署
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaowFISH committed Jan 6, 2025
1 parent abfb788 commit b5b65fc
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Yarn Cache
author: Maiko Tan
description: Cache Yarn dependencies

inputs:
os:
description: |
The operating system to cache dependencies for. This should almost always be `runner.os`.
required: true
default: ${{ runner.os }}

runs:
using: composite
steps:
- name: Get yarn cache directory path
id: yarn-cache-dir-path
shell: bash
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ inputs.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ inputs.os }}-yarn-
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
interval: "monthly"
24 changes: 20 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,23 @@ on:

jobs:
build:
uses: cordiverse/workflows/.github/workflows/build.yml@main
with:
lint: true
test: false
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4

- name: Enable Corepack
run: corepack enable

- name: Cache Yarn dependencies
uses: ./.github/actions/cache
with:
os: ${{ runner.os }}

- name: Install dependencies
run: yarn install

- name: Lint JavaScript
run: yarn build

30 changes: 27 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ on:

jobs:
publish:
uses: cordiverse/workflows/.github/workflows/publish.yml@main
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4

- name: Enable Corepack
run: corepack enable

- name: Cache Yarn dependencies
uses: ./.github/actions/cache
with:
os: ${{ runner.os }}

- name: Install
run: yarn

- name: Build
run: yarn build

- name: Set npm token
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Publish packages
run: yarn pub

0 comments on commit b5b65fc

Please sign in to comment.