Changed npm CD workflow file to use step outputs #4
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
name: npm package CD | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- 'main' | |
jobs: | |
npm_publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Check if PR is merged | |
id: check_merge | |
run: | | |
if [[ "$(git log -1 --pretty=%B "${{ github.event.pull_request.merge_commit_sha }}")" == *"Merge pull request"* ]]; then | |
echo "is_merged=true" >> $GITHUB_OUTPUT | |
else | |
echo "is_merged=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Setup node env | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ./npm-package | |
- name: Build files into dist | |
run: npm run build | |
working-directory: ./npm-package | |
- name: Deploy | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npm run semantic-release | |
working-directory: ./npm-package | |
if: steps.check_merge.outputs.is_merged == 'true' |