Skip to content

Commit

Permalink
chore(ci): added github actions templates
Browse files Browse the repository at this point in the history
  • Loading branch information
gokayform committed Dec 18, 2023
1 parent fc9e82e commit a7bfe1d
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Test
on:
# manual trigger
workflow_dispatch:
# reuse workflow run
workflow_call:
# on pull request
pull_request:
# on push to master branch
push:
branches:
- 'master'
- 'next'
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-package-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-package-
- name: Install dependencies
run: npm i

- name: Run tests
run: npm run test
env:
JF_API_KEY: ${{ secrets.TEST_USER_API_KEY }}

- name: Build package
run: npm run build
40 changes: 40 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish
on:
# on release
release:
types: [released, prereleased]

jobs:
build-test:
uses: ./.github/workflows/build-test.yml
publish:
needs: build-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20

- name: Cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-package-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-package-
- name: Build package
run: npm run build

- name: Publish package
if: github.event_name == 'release' && github.event.release.draft == false
run: |
if [[ ${{ github.event.release.prerelease }} == true || ${{ github.event.release.tag_name }} =~ -alpha|-beta|-rc ]]; then
npm publish --tag next
else
npm publish --tag latest
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit a7bfe1d

Please sign in to comment.