mirror of
https://github.com/zhigang1992/connect.git
synced 2026-01-12 22:46:28 +08:00
100 lines
3.0 KiB
YAML
100 lines
3.0 KiB
YAML
name: Pull Request
|
|
on: [pull_request, workflow_dispatch]
|
|
|
|
jobs:
|
|
check_fork:
|
|
name: Disable jobs for forks
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
is_not_fork: ${{ steps.is_not_fork.outputs.is_not_fork }}
|
|
steps:
|
|
- name: Check for secret
|
|
id: is_not_fork
|
|
env:
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: |
|
|
echo "Is a fork: ${{ env.NPM_TOKEN == '' }}"
|
|
echo "::set-output name=is_not_fork::${{ env.NPM_TOKEN != '' }}"
|
|
|
|
commitlint:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: wagoid/commitlint-github-action@v1
|
|
|
|
code_checks:
|
|
name: Code checks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
- name: Set Node Version
|
|
uses: actions/setup-node@v2-beta
|
|
with:
|
|
node-version: 12.16.1
|
|
- name: Restore lerna cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
node_modules
|
|
*/*/node_modules
|
|
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
|
|
- name: Code Checks
|
|
uses: ./.github/actions/code-checks
|
|
|
|
publish_npm_betas:
|
|
name: Publish NPM beta versions
|
|
runs-on: ubuntu-latest
|
|
needs: [check_fork]
|
|
if: needs.check_fork.outputs.is_not_fork == 'true'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
- name: Set Node Version
|
|
uses: actions/setup-node@v2-beta
|
|
with:
|
|
node-version: 12.16.1
|
|
- name: Restore lerna cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
node_modules
|
|
*/*/node_modules
|
|
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
|
|
- name: Install monorepo deps
|
|
run: yarn --frozen-lockfile
|
|
- name: Bootstrap
|
|
run: yarn lerna bootstrap
|
|
- name: Setup .npmrc
|
|
env:
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
|
|
- name: Get git branch
|
|
id: git-branch
|
|
run: echo "::set-output name=branch::$(git rev-parse --abbrev-ref HEAD | cut -d'/' -f2 )"
|
|
- name: Get git commit
|
|
id: git-commit
|
|
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
|
|
- name: print preid
|
|
env:
|
|
BRANCH: ${{ steps.git-branch.outputs.branch }}
|
|
SHA: ${{ steps.git-commit.outputs.sha }}
|
|
run: echo $BRANCH.$SHA
|
|
- name: Setup git
|
|
run: |
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
- name: Publish to NPM
|
|
env:
|
|
BRANCH: ${{ steps.git-branch.outputs.branch }}
|
|
SHA: ${{ steps.git-commit.outputs.sha }}
|
|
run: yarn lerna publish prepatch --preid alpha.$SHA --dist-tag $BRANCH --yes --no-push
|