Skip to content

Commit

Permalink
Fix/GitHub Action (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
ishiko732 authored Nov 20, 2023
1 parent 44586b3 commit 6e2d013
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 76 deletions.
46 changes: 25 additions & 21 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build docs
run: pnpm run docs
- name: Copy example folder
run: cp -R example docs/example

- name: Deploy to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- uses: pnpm/[email protected]
with:
version: 8.7.1

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build docs
run: pnpm run docs
- name: Copy example folder
run: cp -R example docs/example

- name: Deploy to GitHub Pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs
30 changes: 0 additions & 30 deletions .github/workflows/npm-beta-publish.yml

This file was deleted.

23 changes: 17 additions & 6 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ name: Publish Package to npm.js

on:
release:
types: [published]
repository_dispatch:
types: [publish-npm]
types: [ published ]
pull_request:
types:
- closed

jobs:

Expand All @@ -25,7 +26,17 @@ jobs:
- run: pnpm lint
- run: pnpm test
- run: pnpm build
- uses: JS-DevTools/npm-publish@v2
- name: Determine Target Branch
id: determine-branch
run: echo "::set-output name=branch::${{ github.event.pull_request.base.ref }}"

- name: Determine Tag
id: determine-tag
run: echo "::set-output name=tag::${{ steps.determine-branch.outputs.branch == 'master' && 'latest' || 'beta' }}"

- name: Publish Package
uses: JS-DevTools/npm-publish@v2
with:
token: ${{secrets.npm_token}}
provenance: true
token: ${{secrets.npm_token}}
provenance: true
tag: ${{ steps.determine-tag.outputs.tag }}
24 changes: 5 additions & 19 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,16 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run tests
run: pnpm test

- uses: jwalton/gh-find-current-pr@v1
id: findPr

- name: jest coverage report
uses: ArtiomTr/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
prnumber: ${{ steps.findPr.outputs.number }}

- name: Check test status
id: test-status
run: echo "::set-output name=status::$(if grep -q 'Test failed' test-results.txt; then echo 'failure'; else echo 'success'; fi)"

merge:
needs: test
runs-on: ubuntu-latest
if: ${{ needs.test.outputs.status == 'success' }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Trigger npm-publish workflow
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ishiko732/ts-fsrs
event-type: publish-npm
run: echo "::set-output name=status::$(if grep -q 'Test failed' test-results.txt; then echo 'failure'; else echo 'success'; fi)"

0 comments on commit 6e2d013

Please sign in to comment.