Skip to content

Commit

Permalink
update with slack notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbaliasnikov committed Dec 16, 2024
1 parent 282af6d commit e4cf3c2
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 68 deletions.
47 changes: 47 additions & 0 deletions .github/actions/slack-notify-release/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Slack notification for failed workflow'

description: 'Send a Slack notification for failed workflow.'

inputs:
webhook:
description: 'Slack Incoming Webhook URL'
required: true

runs:
using: composite
steps:
- name: Slack failure notification
if: failure()
uses: slackapi/[email protected]
with:
webhook: ${{ inputs.webhook }}
webhook-type: incoming-webhook
payload: |
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "*🚨 GitHub Workflow Failed!*"
- type: "section"
fields:
- type: "mrkdwn"
text: "*Repository:*\n`${{ github.repository }}`"
- type: "mrkdwn"
text: "*Workflow:*\n`${{ github.workflow }}`"
- type: "mrkdwn"
text: "*Branch:*\n`${{ github.ref_name }}`"
- type: "mrkdwn"
text: "*Triggered By:*\n`${{ github.actor }}`"
- type: "section"
text:
type: "mrkdwn"
text: "You can view the detailed logs and troubleshoot the issue by visiting the link below:"
- type: "actions"
elements:
- type: "button"
text:
type: "plain_text"
text: "View Workflow Logs"
emoji: true
url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
style: "danger"
103 changes: 35 additions & 68 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ on:
description: 'Run tests before release'
required: false
default: false
concurrency-suffix:
type: string
description: 'Suffix to use for release-pr job concurrency.'
publish-to-crates-io:
type: boolean
description: 'Whether to publish to crates.io'
required: false
default: false
update-cargo-lock:
type: boolean
description: 'Whether to update Cargo.lock'
required: false
default: true
org-owner:
type: string
description: 'Organization to add as owner of the crates.'
Expand Down Expand Up @@ -71,48 +77,12 @@ jobs:
config-file: ${{ inputs.config }}
manifest-file: ${{ inputs.manifest }}

- name: Send Slack notification if release failed
if: failure()
uses: slackapi/[email protected]
with:
webhook: ${{ secrets.slack_webhook }}
webhook-type: incoming-webhook
payload: |
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "*🚨 GitHub Release Failed!*"
- type: "section"
fields:
- type: "mrkdwn"
text: "*Repository:*\n`${{ github.repository }}`"
- type: "mrkdwn"
text: "*Workflow:*\n`${{ github.workflow }}`"
- type: "mrkdwn"
text: "*Branch:*\n`${{ github.ref_name }}`"
- type: "mrkdwn"
text: "*Triggered By:*\n`${{ github.actor }}`"
- type: "section"
text:
type: "mrkdwn"
text: "You can view the detailed logs and troubleshoot the issue by visiting the link below:"
- type: "actions"
elements:
- type: "button"
text:
type: "plain_text"
text: "View Workflow Logs"
emoji: true
url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
style: "danger"

update-cargo-lock:
name: ${{ matrix.pr_branch }}
name: Update Cargo.lock
runs-on: ubuntu-latest
needs: release-please
if: ${{ needs.release-please.outputs.prs_created == 'true' }}
if: ${{ needs.release-please.outputs.prs_created == 'true' && inputs.update-cargo-lock }}
strategy:
matrix:
pr_branch: ${{ fromJson(needs.release-please.outputs.prs).*.headBranchName }}
Expand Down Expand Up @@ -154,11 +124,11 @@ jobs:
git push --set-upstream origin ${{ matrix.pr_branch }}
release-crates:
publish-crates:
needs: release-please
name: Crates Release
name: Publish to crates.io
runs-on: ubuntu-latest
if: ${{ needs.release-please.outputs.releases_created == 'true' }}
if: ${{ needs.release-please.outputs.releases_created == 'true' && inputs.publish-to-crates-io }}
strategy:
matrix:
path: ${{ fromJson(needs.release-please.outputs.paths_released) }}
Expand All @@ -167,7 +137,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.gh_token }}
submodules: "recursive"

Expand All @@ -190,33 +159,31 @@ jobs:
working-directory: ${{ matrix.path }}
run: cargo test

# Here should go the step to release packages to crates.io
- name: Release packages to crates.io
shell: 'bash -ex {0}'
working-directory: ${{ matrix.path }}
run: |
echo "${{ matrix.path }}"
cargo login ${{ secrets.cargo_registry_token }}
cargo workspaces publish --from-git
# - name: Update ownership
# shell: 'bash -ex {0}'
# if: success() && inputs.org-owner != ''
# working-directory: ${{ matrix.path }}
# run: |
# ORG_OWNER=${{ inputs.org-owner }}
# cargo login ${{ secrets.cargo_registry_token }}
# for PKG in $(echo '${{ steps.release-plz.outputs.releases }}' | jq -r '.[].package_name'); do
# if cargo owner --list --quiet "${PKG}" 2>/dev/null | grep -q "${ORG_OWNER}"; then
# echo "Owner ${ORG_OWNER} already exists for package ${PKG}."
# elif cargo owner --list --quiet "${PKG}" 2>/dev/null; then
# echo "Adding owner ${ORG_OWNER} to package ${PKG}."
# cargo owner --add "${ORG_OWNER}" "${PKG}"
# else
# echo "Package ${PKG} does not exist on crates.io. Skipping."
# fi
# done

# TODO: create job to update other workspaces
# after successful release of the packages
# update-other-workspaces:
- name: Update ownership
shell: 'bash -ex {0}'
if: success() && inputs.org-owner != ''
working-directory: ${{ matrix.path }}
run: |
ORG_OWNER=${{ inputs.org-owner }}
cargo login ${{ secrets.cargo_registry_token }}
for PKG in $(cargo ws list); do
cargo owner --list --quiet ${PKG} | grep ${ORG_OWNER} || cargo owner --add ${ORG_OWNER} ${PKG}
done
notify-slack-if-fail:
needs: [release-please, update-cargo-lock, publish-crates]
name: Notify Slack
runs-on: ubuntu-latest
if: failure()
steps:
- name: Send Slack notification if release failed
uses: matter-labs/zksync-ci-common/.github/actions/slack-notify-release@aba-release-please-support
with:
webhook: ${{ secrets.slack_webhook }}

0 comments on commit e4cf3c2

Please sign in to comment.