Skip to content

ci(gh-actions): use repository dispatch event for release #63

ci(gh-actions): use repository dispatch event for release

ci(gh-actions): use repository dispatch event for release #63

Workflow file for this run

name: Test and Build
on:
pull_request:
push:
branches: [ latest ]
permissions:
contents: read
jobs:
build:
name: Build (Node.js v${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- 18
- 20
- 21
- 22
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}.x
- name: Install dependencies
run: npm install
- name: Run Lint
run: npm run lint
- name: Run Test
run: npm run test
- name: Report Codacy coverage
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coverage/lcov.info
- name: Run Build
run: npm run build
- name: Audit, fix outdated dependencies and rebuild
run: |
npm list --outdated
npm audit || true
npm audit fix || true
npm list --outdated
npm run build
trigger-release:
if: github.ref == 'refs/heads/latest'
name: Trigger Release on latest
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Create semantic-release repository dispatch event
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/dispatches \
-f "event_type=semantic-release" \
-F "client_payload[commit_message]=${{ github.event.head_commit.message }}"