Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .github/workflows/npm-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
description: 'Release version to publish'
required: true
type: string
quiet:
description: 'Leave the Slack notification to the caller'
type: boolean
default: false

permissions:
id-token: write
Expand Down Expand Up @@ -50,21 +54,17 @@ jobs:
- name: Publish to npm
run: npm publish --provenance --access public


- name: Slack Notification (Always)
if: always()
run: |
MESSAGE="NPM publish for version ${{ inputs.release-version }} completed with status: ${{ job.status }}"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }}

- name: Slack Notification (Error)
if: failure()
run: |
MESSAGE="NPM publish for version ${{ inputs.release-version }} FAILED!"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_ERROR_WEBHOOK }}
# Slack, when run on its own: success to the general channel, failure to the
# important one. release.yaml reports the publishes it calls itself.
- name: Notify
if: ${{ !cancelled() && !inputs.quiet }}
uses: Apicurio/apicurio-github-actions/notify-slack@bd19cbe33797325a571cd7ffd58f639b62e128a2 # v2.4.0
with:
level: ${{ job.status == 'success' && 'general' || 'important' }}
text: "${{ job.status == 'success' && format(':package: {0}: {1} published {2}', github.repository, github.workflow, inputs.release-version) || format(':x: {0}: {1} failed for {2}', github.repository, github.workflow, inputs.release-version) }}"
link: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
mention: ${{ job.status != 'success' && github.actor || '' }}
machine-users: apitomy-ci
user-map: ${{ secrets.SLACK_USER_MAP }}
important-webhook: ${{ secrets.SLACK_IMPORTANT_NOTIFICATION_WEBHOOK }}
general-webhook: ${{ secrets.SLACK_GENERAL_NOTIFICATION_WEBHOOK }}
44 changes: 22 additions & 22 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
uses: ./.github/workflows/npm-publish.yaml
with:
release-version: ${{ needs.release.outputs.release-version }}
quiet: true
secrets: inherit


Expand Down Expand Up @@ -103,25 +104,24 @@ jobs:
fi


- name: Slack Notification (Always)
if: always()
run: |
NPM_STATUS="${{ needs.npm-publish.result }}"
if [[ "$NPM_STATUS" != "success" ]]; then
MESSAGE="Release ${{ needs.release.outputs.release-version }} completed with warnings. NPM: $NPM_STATUS. Manual retry may be needed."
else
MESSAGE="Release ${{ needs.release.outputs.release-version }} completed successfully"
fi
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }}

- name: Slack Notification (Publishing Failures)
if: needs.npm-publish.result != 'success'
run: |
MESSAGE="Release ${{ needs.release.outputs.release-version }}: NPM publish failed (${{ needs.npm-publish.result }}). Retry at https://github.com/${{ github.repository }}/actions/workflows/npm-publish.yaml"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"warning\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_ERROR_WEBHOOK }}
# Slack: the outcome of the whole release, publishes included. Success to
# the general channel, a failure to the important one, mentioning whoever
# ran it. A failed publish can be re-run on its own from its workflow.
notify:
name: Notify
needs: [release, npm-publish, finalize]
if: ${{ !cancelled() && github.repository_owner == 'Apitomy' }}
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Notify
uses: Apicurio/apicurio-github-actions/notify-slack@bd19cbe33797325a571cd7ffd58f639b62e128a2 # v2.4.0
with:
level: ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && 'important' || 'general' }}
text: "${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && format(':x: {0}: release {1} failed (release {2}, npm-publish {3}, finalize {4})', github.repository, needs.release.outputs.release-version, needs.release.result, needs.npm-publish.result, needs.finalize.result) || format(':rocket: {0} {1} released', github.repository, needs.release.outputs.release-version) }}"
link: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
mention: ${{ (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) && github.actor || '' }}
machine-users: apitomy-ci
user-map: ${{ secrets.SLACK_USER_MAP }}
important-webhook: ${{ secrets.SLACK_IMPORTANT_NOTIFICATION_WEBHOOK }}
general-webhook: ${{ secrets.SLACK_GENERAL_NOTIFICATION_WEBHOOK }}
29 changes: 13 additions & 16 deletions .github/workflows/update-website.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,17 @@ jobs:
git commit -m "Automated Update For Apitomy OpenAPI Editor Release Version: ${{ env.RELEASE_VERSION }}"
git push

- name: Slack Notification (Always)
if: always()
run: |
MESSAGE="'${{ github.workflow }}/${{ github.job }}' job completed with status: ${{ job.status }}"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }}

- name: Slack Notification (Error)
# Slack, failure only: the release's own message covers the success.
# Runs triggered by the release are apitomy-ci's, so nobody is mentioned
# then; a run started by hand mentions whoever started it.
- name: Notify
if: failure()
run: |
MESSAGE="'${{ github.workflow }}/${{ github.job }}' job FAILED!"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_ERROR_WEBHOOK }}
uses: Apicurio/apicurio-github-actions/notify-slack@bd19cbe33797325a571cd7ffd58f639b62e128a2 # v2.4.0
with:
level: important
text: ":x: ${{ github.repository }}: ${{ github.workflow }} failed"
link: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
mention: ${{ github.actor }}
machine-users: apitomy-ci
user-map: ${{ secrets.SLACK_USER_MAP }}
important-webhook: ${{ secrets.SLACK_IMPORTANT_NOTIFICATION_WEBHOOK }}
34 changes: 17 additions & 17 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ jobs:
npm run lint
npm run build

- name: Slack Notification (Always)
if: github.event_name == 'push' && always()
run: |
MESSAGE="'${{ github.workflow }}/${{ github.job }}' job completed with status: ${{ job.status }}"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_NOTIFICATION_WEBHOOK }}

- name: Slack Notification (Error)
if: github.event_name == 'push' && failure()
run: |
MESSAGE="'${{ github.workflow }}/${{ github.job }}' job FAILED!"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.SLACK_ERROR_WEBHOOK }}
# Slack: a failed push goes to the general channel. Success, PR runs and a
# run cancelled by hand say nothing (failure() stays true when a run that
# already failed is cancelled).
notify:
name: Notify
needs: [build-verify]
if: failure() && !cancelled() && github.event_name == 'push'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Notify
uses: Apicurio/apicurio-github-actions/notify-slack@bd19cbe33797325a571cd7ffd58f639b62e128a2 # v2.4.0
with:
level: general
text: ":x: ${{ github.repository }}: ${{ github.workflow }} failed on ${{ github.ref_name }} at ${{ github.sha }}"
link: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
general-webhook: ${{ secrets.SLACK_GENERAL_NOTIFICATION_WEBHOOK }}
Loading