This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
ci: update of files from global .github repo (#158) #129
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 action is centrally managed in https://github.com/asyncapi/.github/ | |
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo | |
# It does magic only if there is package.json file in the root of the project | |
name: Release - if Node project | |
on: | |
push: | |
branches: | |
- master | |
# below lines are not enough to have release supported for these branches | |
# make sure configuration of `semantic-release` package mentions these branches | |
- next-spec | |
- next-major | |
- next-major-spec | |
- beta | |
- alpha | |
jobs: | |
test-nodejs: | |
# We just check the message of first commit as there is always just one commit because we squash into one before merging | |
# "commits" contains array of objects where one of the properties is commit "message" | |
# Release workflow will be skipped if release conventional commits are not used | |
if: | | |
startsWith( github.repository, 'asyncapi/' ) && | |
(startsWith( github.event.commits[0].message , 'fix:' ) || | |
startsWith( github.event.commits[0].message, 'fix!:' ) || | |
startsWith( github.event.commits[0].message, 'feat:' ) || | |
startsWith( github.event.commits[0].message, 'feat!:' )) | |
name: Test NodeJS release on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows | |
run: | | |
git config --global core.autocrlf false | |
git config --global core.eol lf | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Check if Node.js project and has package.json | |
id: packagejson | |
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" | |
shell: bash | |
- if: steps.packagejson.outputs.exists == 'true' | |
name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 14 | |
cache: 'npm' | |
cache-dependency-path: '**/package-lock.json' | |
- if: steps.packagejson.outputs.exists == 'true' | |
name: Install dependencies | |
run: npm install | |
- if: steps.packagejson.outputs.exists == 'true' | |
name: Run test | |
run: npm test | |
- if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel | |
name: Report workflow run status to Slack | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: repo,action,workflow | |
text: 'Release workflow failed in testing job' | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} | |
release: | |
needs: [test-nodejs] | |
name: Publish to any of NPM, Github, and Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows | |
run: | | |
git config --global core.autocrlf false | |
git config --global core.eol lf | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Check if Node.js project and has package.json | |
id: packagejson | |
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" | |
- if: steps.packagejson.outputs.exists == 'true' | |
name: Setup Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 14 | |
- if: steps.packagejson.outputs.exists == 'true' | |
name: Install dependencies | |
run: npm install | |
- if: steps.packagejson.outputs.exists == 'true' | |
name: Publish to any of NPM, Github, and Docker Hub | |
id: release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
GIT_AUTHOR_NAME: asyncapi-bot | |
GIT_AUTHOR_EMAIL: [email protected] | |
GIT_COMMITTER_NAME: asyncapi-bot | |
GIT_COMMITTER_EMAIL: [email protected] | |
run: npm run release | |
- if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel | |
name: Report workflow run status to Slack | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: repo,action,workflow | |
text: 'Release workflow failed in release job' | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} |