Skip to content

Commit

Permalink
👷 (devx): Create danger check ci script
Browse files Browse the repository at this point in the history
Allow the possibility to run it locally.
For now, we need to set a github token because the repo is private.
  • Loading branch information
aussedatlo committed Apr 2, 2024
1 parent c324e3c commit 77ce8ef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/actions/danger-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -e

is_running_on_github_actions() {
[ -n "$CI" ] && [ -n "$GITHUB_ACTIONS" ]
}

run_danger_on_github_actions() {
echo "Script is running within GitHub Actions workflow."
pnpm danger ci --dangerfile danger/dangerfile.ts --failOnErrors
}

run_danger_on_local() {
echo "Script is running locally."
pnpm danger pr --dangerfile danger/dangerfile.ts https://github.com/LedgerHQ/device-sdk-ts/pull/${1}
}

if is_running_on_github_actions; then
run_danger_on_github_actions
else
if [ -z "$1" ]; then
echo "Argument PR number is missing"
exit 1
fi
run_danger_on_local "$1"
fi

2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
# Workaround when using custom runners
# https://github.com/danger/danger-js/issues/1374
DANGER_GITHUB_API_BASE_URL: "https://api.github.com"
run: pnpm danger ci --dangerfile danger/dangerfile.ts --failOnErrors
run: ./.github/actions/danger-check.sh

health-check:
name: Pass health check
Expand Down

0 comments on commit 77ce8ef

Please sign in to comment.