fix: trigger pipeline on merge pull request #253
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | |
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | |
name: Node.js Package | |
on: | |
push: | |
paths-ignore: | |
- "README.md" | |
- "CHANGELOG.md" | |
pull_request: | |
types: | |
- closed | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
if: | | |
github.event_name != 'pull_request' || | |
github.event.pull_request.merged == true | |
strategy: | |
matrix: | |
node: [19.7] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node ${{ matrix.node }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node }} | |
# TODO: cache node packages | |
- name: Install Node Packages | |
run: npm install | |
- name: Check Code Format | |
run: npm run lint | |
# // TODO: https://www.pluralsight.com/guides/how-to-test-react-components-in-typescript | |
# - name: Test Code | |
# run: npm run test -- --watchAll=false | |
build: | |
needs: [test] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19.7 | |
- name: Setup Git | |
run: | | |
git config --local user.name github-actions | |
git config --local user.email [email protected] | |
# TODO: cache node packages | |
- name: Install Node Packages | |
run: npm install --only=dev | |
- name: Build Package | |
run: npm run build | |
- name: Push Build Files | |
run: | | |
git add lib/* | |
if ! git diff --staged --quiet; then | |
git commit -m "push build files [skip ci]" | |
git push | |
fi | |
release: | |
needs: [build] | |
concurrency: release | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19.7 | |
# TODO: group release dependencies | |
- name: Install Node Packages | |
run: npm install --only=dev | |
- name: Publish Semantic Release | |
env: | |
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
run: npx semantic-release |