Commit 08c42ed7 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'enable-danger-for-forks' into 'master'

Enable danger review for forks

See merge request gitlab-org/gitlab!57097
parents e1ac292a eb4c5faa
...@@ -234,7 +234,15 @@ danger-review: ...@@ -234,7 +234,15 @@ danger-review:
- run_timed_command "bundle install --jobs=$(nproc) --path=vendor --retry=3 --quiet --with danger" - run_timed_command "bundle install --jobs=$(nproc) --path=vendor --retry=3 --quiet --with danger"
- run_timed_command "retry yarn install --frozen-lockfile" - run_timed_command "retry yarn install --frozen-lockfile"
script: script:
- run_timed_command "bundle exec danger --fail-on-errors=true --verbose" - >
if [ -z "$DANGER_GITLAB_API_TOKEN" ]; then
# Force danger to skip CI source GitLab and fallback to "local only git repo".
unset GITLAB_CI
# We need to base SHA to help danger determine the base commit for this shallow clone.
run_timed_command "bundle exec danger dry_run --fail-on-errors=true --verbose --base='$CI_MERGE_REQUEST_DIFF_BASE_SHA'"
else
run_timed_command "bundle exec danger --fail-on-errors=true --verbose"
fi
update-danger-review-cache: update-danger-review-cache:
extends: extends:
......
...@@ -1110,7 +1110,7 @@ ...@@ -1110,7 +1110,7 @@
.review:rules:danger: .review:rules:danger:
rules: rules:
- if: '$DANGER_GITLAB_API_TOKEN && $CI_MERGE_REQUEST_IID' - if: '$CI_MERGE_REQUEST_IID'
############### ###############
# Setup rules # # Setup rules #
......
...@@ -150,16 +150,13 @@ at GitLab so far: ...@@ -150,16 +150,13 @@ at GitLab so far:
## Limitations ## Limitations
- Danger output is not added to a merge request comment if working on Danger is run but its output is not added to a merge request comment if working
a fork. This happens because the secret variable from the canonical on a fork. This happens because the secret variable from the canonical project
project is not shared to forks. is not shared to forks. To work around this, you can add an [environment
To work around this, you can add an [environment variable](../ci/variables/README.md) called `DANGER_GITLAB_API_TOKEN` with a
variable](../ci/variables/README.md) called personal API token to your fork. That way the danger comments are made from CI
`DANGER_GITLAB_API_TOKEN` with a personal API token to your using that API token instead. Making the variable
fork. That way the danger comments are made from CI using that [masked](../ci/variables/README.md#mask-a-custom-variable) makes sure it
API token instead. doesn't show up in the job logs. The variable cannot be
Making the variable [protected](../ci/variables/README.md#protect-a-custom-variable), as it needs
[masked](../ci/variables/README.md#mask-a-custom-variable) makes sure to be present for all feature branches.
it doesn't show up in the job logs. The variable cannot be
[protected](../ci/variables/README.md#protect-a-custom-variable),
as it needs to be present for all feature branches.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment