ci: 👷 use discord notification organization action instead of local #20
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: | |
- '**' | |
permissions: | |
contents: read | |
actions: read | |
checks: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: false | |
env: | |
PROJECT_NAME: ${{ github.event.repository.name }} | |
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 | |
if: always() | |
id: testsreport | |
with: | |
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: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
# Check the Quality Gate status. | |
- name: SonarQube Quality Gate check | |
id: sonarqube-quality-gate-check | |
uses: sonarsource/sonarqube-quality-gate-action@master | |
# Force to fail step after specific time. | |
timeout-minutes: 5 | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: https://sonarcloud.io | |
- name: Notify Discord | |
if: always() | |
uses: quinck-io/actions-notify-discord@main | |
with: | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ job.status }} | |
projectName: ${{ env.PROJECT_NAME }} | |
sonarProjectKey: quinck-io_collections | |
sonarQualityGateStatus: ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }} | |
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: quinck-io/actions-notify-discord@main | |
with: | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ job.status }} | |
projectName: ${{ env.PROJECT_NAME }} |