Merge pull request #1891 from Adslot/renovate-codecov-codecov-action-5.x #2728
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node: [22.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{matrix.node}} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{matrix.node}} | |
- run: npm -v | |
- run: npm ci --update-notifier=false | |
- run: npm run type-check | |
- run: | | |
npm run generate-types | |
git diff --exit-code | |
- run: npm run dist | |
- name: Deploy docs to Netlify | |
run: | | |
BRANCH_NAME="" | |
if [[ ${{github.ref}} == "refs/heads/master" ]]; then | |
BRANCH_NAME="master" | |
else | |
# Truncate branch name at 37 characters per alias requirement: https://cli.netlify.com/commands/deploy/ | |
BRANCH_NAME=${{github.head_ref}} | |
BRANCH_NAME=${BRANCH_NAME:0:37} | |
fi | |
NETLIFY_AUTH_TOKEN=${{secrets.NETLIFY_AUTH_TOKEN}} NETLIFY_SITE_ID=${{secrets.NETLIFY_SITE_ID}} \ | |
npx netlify-cli deploy --dir=docs --message="${BRANCH_NAME}" --alias="${BRANCH_NAME}" | |
- name: Notify Slack channel | |
if: always() && job.status != 'success' && github.ref == 'refs/heads/master' | |
env: | |
GITHUB_WORKFLOW: ${{env.GITHUB_WORKFLOW}} | |
GITHUB_RUN_NUMBER: ${{env.GITHUB_RUN_NUMBER}} | |
GITHUB_SHA: ${{env.GITHUB_SHA}} | |
GITHUB_REPOSITORY: ${{env.GITHUB_REPOSITORY}} | |
GITHUB_REF: ${{env.GITHUB_REF}} | |
run: | | |
GIT_SHA_SHORT=$(git rev-parse --short ${GITHUB_SHA}) | |
NOTIFICATION_TEXT="${GITHUB_WORKFLOW} [${{matrix.node}}] #${GITHUB_RUN_NUMBER} (${GIT_SHA_SHORT}) of ${GITHUB_REPOSITORY}@${GITHUB_REF}" | |
SUCCESS_NOTIFICATION="${NOTIFICATION_TEXT} successful" | |
SUCCESS_COLOR="good" | |
FAILURE_NOTIFICATION="${NOTIFICATION_TEXT} failed" | |
FAILURE_COLOR="danger" | |
CANCELLED_NOTIFICATION="${NOTIFICATION_TEXT} cancelled" | |
CANCELLED_COLOR="warning" | |
if [[ ${{job.status}} == "success" ]]; then | |
TEXT=$SUCCESS_NOTIFICATION | |
COLOR=$SUCCESS_COLOR | |
elif [[ ${{job.status}} == "failure" ]]; then | |
TEXT=$FAILURE_NOTIFICATION | |
COLOR=$FAILURE_COLOR | |
elif [[ ${{job.status}} == "cancelled" ]]; then | |
TEXT=$CANCELLED_NOTIFICATION | |
COLOR=$CANCELLED_COLOR | |
fi | |
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
--url ${{secrets.SLACK_WEBHOOK}} \ | |
-d @- << EOF | |
{ | |
"attachments": [ | |
{ | |
"color": "${COLOR}", | |
"text": "${TEXT}" | |
} | |
] | |
} | |
EOF |