# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json on: workflow_call: inputs: remove-previous-comments: description: Configures Danger to always remove previous comments and add a new one instead of editing the same comment. default: false type: boolean required: false cancel-running-jobs: description: Cancel currently in progress jobs when new ones are added. default: true type: boolean required: false secrets: github-token: required: true concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ inputs.cancel-running-jobs }} jobs: dangermattic: runs-on: ubuntu-latest steps: - name: 📥 Checkout Repo uses: actions/checkout@v4 with: fetch-depth: 100 - name: 💎 Ruby Setup uses: ruby/setup-ruby@v1 with: bundler-cache: true - name: ☢️ Danger PR Check env: PR_URL: ${{ github.event.pull_request.html_url }} READ_ONLY_MODE: ${{ github.event.pull_request.head.repo.fork || github.actor == 'dependabot[bot]' }} REMOVE_PREVIOUS_COMMENTS: ${{ inputs.remove-previous-comments }} DANGER_GITHUB_API_TOKEN: ${{ secrets.github-token || secrets.GITHUB_TOKEN }} run: | echo "--- 🏃 Running Danger: PR Check" if [ "$READ_ONLY_MODE" = true ]; then danger_output=$(bundle exec danger pr "$PR_URL" --verbose) echo "$danger_output" if echo "$danger_output" | grep -q "Errors:"; then echo "Danger encountered errors." exit 1 fi else bundle exec danger --fail-on-errors=true --danger_id=pr-check $([ "$REMOVE_PREVIOUS_COMMENTS" = true ] && echo "--remove-previous-comments") fi