From 293b2c3f08875c1e02815ec9ea725cbec38e9974 Mon Sep 17 00:00:00 2001 From: Brent Hosie Date: Tue, 29 Mar 2022 14:58:56 -0600 Subject: [PATCH] PDCL-7927: add yaml file for notifying slack of release --- .github/workflows/notify.yaml | 47 +++++++++++++++++++++++++++++++ .github/workflows/npm-publish.yml | 4 +-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/notify.yaml diff --git a/.github/workflows/notify.yaml b/.github/workflows/notify.yaml new file mode 100644 index 0000000..f248747 --- /dev/null +++ b/.github/workflows/notify.yaml @@ -0,0 +1,47 @@ +name: CI notify + +# Only trigger, when the build workflow succeeded +on: + workflow_run: + workflows: ['Node.js Package'] + types: + - completed + +jobs: + notify-on-success: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/checkout@v2 + - name: Get latest tag + uses: oprypin/find-latest-tag@v1 + with: + repository: "${{ github.repository }}" # The repository to scan. + releases-only: true # We know that all relevant tags have a GitHub release for them. + id: repoTag # The step ID to refer to later. + - name: Show ENV + run: env + - name: Notify Slack of Release + uses: tokorom/action-slack-incoming-webhook@main + env: + INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + text: "A new version of ${{ github.event.repository.full_name }}[${{ steps.repoTag.outputs.tag }}] has been released" + attachments: | + [ + { + "color": "good", + "author_name": "${{ github.actor }}", + "author_icon": "${{ github.event.sender.avatar_url }}", + "fields": [ + { + "title": "Repo URL", + "value": "${{ github.event.repository.html_url }}" + }, + { + "title": "See Releases", + "value": "${{ github.event.repository.html_url }}/releases" + } + ] + } + ] diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 4348708..aa0b044 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -5,7 +5,7 @@ name: Node.js Package on: release: - types: [published] + types: [created] jobs: publish-npm: @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 14 registry-url: https://registry.npmjs.org/ - run: npm publish env: