From 74ce97a73171f217b3cf7acb4169ddc6cacf8ec2 Mon Sep 17 00:00:00 2001 From: Mehdi ABAAKOUK Date: Tue, 26 Sep 2023 16:19:15 +0200 Subject: [PATCH] ci: add CF Pages -> Slack notifications (#2270) This allows to track deployment. --- .github/workflows/deploy-cf.yaml | 26 +++++++++++++++++ cf-build.sh | 49 ++++++++++++++++++++++++++++++++ package.json | 3 +- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy-cf.yaml create mode 100755 cf-build.sh diff --git a/.github/workflows/deploy-cf.yaml b/.github/workflows/deploy-cf.yaml new file mode 100644 index 0000000000..9c27312a3c --- /dev/null +++ b/.github/workflows/deploy-cf.yaml @@ -0,0 +1,26 @@ +name: Deployment trigger +permissions: read-all + +on: + push: + branches: + - main + +concurrency: + # yamllint disable-line rule:line-length + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + deploy: + timeout-minutes: 5 + runs-on: ubuntu-20.04 + steps: + - name: Deployment start + if: always() && github.event_name == 'push' && github.ref == 'refs/heads/main' + # yamllint disable-line rule:line-length + # nosemgrep: yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha.third-party-action-not-pinned-to-commit-sha + uses: Mergifyio/gha-slack-notification@main + with: + type: deploy-start + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEPLOYMENT_WEBHOOK_URL_RELEASES }} diff --git a/cf-build.sh b/cf-build.sh new file mode 100755 index 0000000000..ffd1775f08 --- /dev/null +++ b/cf-build.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +set -e +set -o pipefail + +slack_message () { + local message="$1" + local filename="docs-build-${CF_PAGES_COMMIT_SHA}.log" + + local payload=$( +cat < build.log +slack_message "*Building (${CF_PAGES_BRANCH}/${CF_PAGES_COMMIT_SHA}) of docs *" +exit() { slack_message "*Deployment (${CF_PAGES_BRANCH}/${CF_PAGES_COMMIT_SHA}) of docs finished ${emoji}*\\\nConclusion: ${conclusion}"; } +conclusion="failure" emoji="💥" +trap exit EXIT + +gatsby build 2>&1 | tee -a build.log + +conclusion="success" emoji="🦾" diff --git a/package.json b/package.json index 2f9c7d5911..1fb26528ee 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "private": true, "scripts": { "build": "gatsby build", + "cf-build": "bash ./cf-build.sh", "serve": "gatsby serve", "develop": "gatsby develop", "eslint": "eslint src", @@ -90,4 +91,4 @@ "optionalDependencies": { "@parcel/watcher-linux-x64-glibc": "^2.3.0" } -} \ No newline at end of file +}