Feature: Expose --id to rules
I want to get the value of danger ci --id to use in rules.
The intent is to run danger twice on CI pipeline, first time early to report coding errors, second time late to grab any artifacts from CI jobs and format them as comments.
The property itself is here:
- https://github.com/danger/danger-js/blob/0b2c1d33d3336b80437d48af1c851e97751e3247/source/commands/ci/runner.ts#L66
for now i'll use environment variable in my rules:
export const DANGER_ID = process.env.DANGER_ID || 'Danger';
but that's just duplicating the same thing, I need to set the env and need to pass --id arg when executing danger second time on the pipeline
Ideas, guides? on how to implement this?
We run two different Dangerfiles in our repo, so we don't need access to the ID within a single Dangerfile. Is that technique worthwhile for you @glensc?
danger ci --id "$1" --dangerfile "$DANGER_FILES_DIR/$1.ts" where $1 is the name of the file we're executing.
This then lets us easily trigger different danger files from different events or steps in a Github Actions Workflow, and not have them trip over each other.
Feels like a field which could be available in the main danger export to me
@orta, so something here:
- https://github.com/danger/danger-js/blob/0b2c1d33d3336b80437d48af1c851e97751e3247/source/runner/jsonToDSL.ts#L54-L67
just add root level dangerId there? or as some structure? or under utils?
I think dangerID in there would be 👍🏻 (utils is for functions IMO)