ci: 💚 fi qa job test step #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: Collections DevOps | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- '**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: false | |
env: | |
PROJECT_NAME: collections | |
jobs: | |
qa: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint | |
run: npm run lint | |
- name: Test | |
run: npm run test:jsonReporter | |
- uses: dorny/test-reporter@v1 | |
with: | |
artifact: test-results # artifact name | |
name: Unit Tests # Name of the check run which will be created | |
path: 'test-results.json' # Path to test results (inside artifact .zip) | |
reporter: mocha-json # Format of test results | |
- name: Notify Discord | |
if: always() | |
uses: ./.github/actions/notify-discord | |
with: | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ job.status }} | |
projectName: ${{ env.PROJECT_NAME }} | |
publish: | |
runs-on: ubuntu-latest | |
needs: qa | |
if: ${{ github.ref_name == 'master' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build project | |
run: npm run build | |
- name: Publish to NPM | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | |
PUBLISHED_VERSION=$(npm show @quinck/collections version) | |
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') | |
if [ "${PUBLISHED_VERSION}" = "${PACKAGE_VERSION}" ]; then | |
echo "The current package version has already been published" | |
else | |
echo "Do pubblication" | |
npm publish --access public | |
fi | |
- name: Notify Discord | |
if: always() | |
uses: ./.github/actions/notify-discord | |
with: | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ job.status }} | |
projectName: ${{ env.PROJECT_NAME }} |