-
-
Notifications
You must be signed in to change notification settings - Fork 7
Feat: Allow repo specific dangerfile. #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
aac9829
a2e8261
7e4598b
c4c0849
bb559db
e765013
ccf73eb
8c62a42
2cc1eb3
283729d
5cbc268
5cdeef3
49e1cb3
f2dfd1a
0a9ab78
3b57951
5a3a11d
5be5614
240ed21
35ba335
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,14 @@ inputs: | |
| description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}' | ||
| required: false | ||
| default: ${{ github.token }} | ||
| extra-dangerfile: | ||
| description: 'Path to additional dangerfile to run after the main checks' | ||
| type: string | ||
| required: false | ||
| extra-install-packages: | ||
| description: 'Additional apt packages to install in the DangerJS container (space-separated package names)' | ||
| type: string | ||
| required: false | ||
|
|
||
| outputs: | ||
| outcome: | ||
|
|
@@ -28,12 +36,25 @@ runs: | |
| shell: pwsh | ||
| run: Get-Content '${{ github.action_path }}/danger.properties' | Tee-Object $env:GITHUB_OUTPUT -Append | ||
|
|
||
| # Validate extra-install-packages to prevent code injection | ||
| - name: Validate package names | ||
| if: ${{ inputs.extra-install-packages }} | ||
| shell: bash | ||
| run: | | ||
| packages="${{ inputs.extra-install-packages }}" | ||
| # Only allow alphanumeric characters, hyphens, periods, plus signs, underscores, and spaces | ||
| if ! echo "$packages" | grep -E '^[a-zA-Z0-9._+-]+( [a-zA-Z0-9._+-]+)*$' > /dev/null; then | ||
| echo "::error::Invalid package names in extra-install-packages. Only alphanumeric characters, hyphens, periods, plus signs, underscores, and spaces are allowed." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Using a pre-built docker image in GitHub container registry instead of NPM to reduce possible attack vectors. | ||
| - name: Run DangerJS | ||
| id: danger | ||
| - name: Setup container | ||
| shell: bash | ||
| run: | | ||
| docker run \ | ||
| # Start a detached container with all necessary volumes and environment variables | ||
| docker run -td --name danger \ | ||
| --entrypoint /bin/bash \ | ||
| --volume ${{ github.workspace }}:/github/workspace \ | ||
| --volume ${{ github.action_path }}:${{ github.action_path }} \ | ||
| --volume ${{ github.event_path }}:${{ github.event_path }} \ | ||
|
|
@@ -42,5 +63,21 @@ runs: | |
| -e "INPUT_ARGS" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true \ | ||
| -e GITHUB_TOKEN="${{ inputs.api-token }}" \ | ||
|
||
| -e DANGER_DISABLE_TRANSPILATION="true" \ | ||
| -e EXTRA_DANGERFILE_INPUT="${{ inputs.extra-dangerfile }}" \ | ||
| ghcr.io/danger/danger-js:${{ steps.config.outputs.version }} \ | ||
| --failOnErrors --dangerfile ${{ github.action_path }}/dangerfile.js | ||
vaind marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| -c "sleep infinity" | ||
|
|
||
lucas-zimerman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Setup additional packages | ||
| if: ${{ inputs.extra-install-packages }} | ||
| shell: bash | ||
| run: | | ||
| docker exec --user root danger apt-get update | ||
| echo "Installing packages: ${{ inputs.extra-install-packages }}" | ||
lucas-zimerman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| docker exec --user root danger sh -c "set -e && apt-get install -y --no-install-recommends ${{ inputs.extra-install-packages }}" | ||
| echo "All additional packages installed successfully." | ||
lucas-zimerman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Run DangerJS | ||
| id: danger | ||
| shell: bash | ||
| run: | | ||
| docker exec --user $(id -u) danger danger ci --fail-on-errors --dangerfile ${{ github.action_path }}/dangerfile.js | ||
Uh oh!
There was an error while loading. Please reload this page.