From d1906566be156c169f707a3c3a1f88656e07f31c Mon Sep 17 00:00:00 2001 From: jeremy Date: Sat, 12 Oct 2024 10:47:04 +0200 Subject: [PATCH] Create npm-publish.yml --- .github/workflows/npm-publish.yml | 112 ++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..1ff441d --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,112 @@ +name: NPM publish + +on: + push: + branches: + - 'main' + +env: + success: ✅ + failure: 🔴 + cancelled: ❌ + skipped: ⭕ + node_version: 20 + true: ✅ + false: 🔴 + +jobs: + test: + name: Test + runs-on: ubuntu-22.04 + steps: + - name: Update packages + run: sudo apt-get update + + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ env.node_version }} + registry-url: https://registry.npmjs.org/ + cache: 'npm' + + - name: Install Dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Run tests + run: npm test + + - name: Notification + if: ${{ always() }} + uses: appleboy/telegram-action@master + with: + token: ${{ secrets.BOT_TOKEN }} + to: ${{ secrets.CHAT_ID }} + disable_web_page_preview: true + message: | + Test ${{ env[job.status] }} by ${{ github.actor }} for commit in ${{ github.ref_name }} branch. + Comment: ${{ github.event.commits[0].message }} + + Repository: ${{ github.repository }} + See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }} + Github action: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + + + # release: + # needs: test + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + + # - id: release + # uses: halvardssm/github-action-tag-release@1.0.0 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # path: './package.json' # optional, will use ./package.json by default + + # - run: | + # echo 'Release created: ${{steps.release.outputs.release_created}}' # 'true' or 'false' + # echo 'Release exists: ${{steps.release.outputs.release_exists}}' # 'true' or 'false' + # echo 'Release tag: ${{steps.version.outputs.release_tag}}' # The tag from package.json + + # - name: Notification + # if: ${{ always() }} + # uses: appleboy/telegram-action@master + # with: + # token: ${{ secrets.BOT_TOKEN }} + # to: ${{ secrets.CHAT_ID }} + # message: | + # Repository: ${{ github.repository }} + # Release : ${{ env[steps.release.outputs.release_created] }} + # Tag: ${{ steps.version.outputs.release_tag }} + + # publish-npm: + # needs: release + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + + # - uses: actions/setup-node@v3 + # with: + # node-version: 20 + # registry-url: https://registry.npmjs.org/ + + # - run: npm ci + # - run: npm publish + # env: + # NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + + # - name: Notification + # if: ${{ always() }} + # uses: appleboy/telegram-action@master + # with: + # token: ${{ secrets.BOT_TOKEN }} + # to: ${{ secrets.CHAT_ID }} + # message: | + # Repository: ${{ github.repository }} + # npm publish : ${{ env[job.status] }}