Skip to content

Commit

Permalink
Merge pull request #10 from Siteimprove/configurable-config
Browse files Browse the repository at this point in the history
Configurable config file location
  • Loading branch information
Jym77 committed Mar 7, 2023
2 parents 83328e3 + e55601c commit e91487c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion check-run/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This version splits the actions in two parts: one that checks whether the action should run and does some basic setup (checkout the repository, handle the `help` command, …); the other that performs the actual action. Between the two actions, it is possible to interpose repository-specific commands, especially the ones that are used by all PR Commands flow (e.g., `actions/setup-node`, `install`, `build`, or `test`, …)

The `config.json` file, options, and token restriction follows the exact same syntax as for the [advanced action](../advanced).
The configuration file can be parametrised via the `configFile` input, the default location is `./config/pr-commands.json`. It otherwise follows the exact same syntax as for the [advanced action](../advanced).

<!-- start usage -->
**.github/workflows/pr-command.yaml**
Expand All @@ -22,6 +22,10 @@ jobs:
with:
# Personal access token (PAT) used to fetch the repository and add reaction on comment (See note about token)
token: ''
# Optional prefix to trigger the command, defaults to "!pr"
prefix: "Magic bot, please run"
# Configuration file location (relative to top-level directory), defaults to "./config/pr-commands.json"
configFile: "./.pr-commands/config.json"

# At this point, repository specific setup can be performed before running the actual PR commands.
# The repository has been checked out, on the latest commit on the PR that triggered the workflow.
Expand Down
9 changes: 7 additions & 2 deletions check-run/check/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ inputs:
description: "Prefix for commands, defaults to '!pr"
required: false
default: '!pr'
configFile:
description: "Location of the configuration file"
required: false
default: "./config/pr-commands.json"


runs:
using: "composite"
Expand Down Expand Up @@ -52,7 +57,7 @@ runs:
- name: "Does configuration file exists?"
if: steps.check.outputs.should_run == 'true'
run: |
if [[ -f ./.pr-commands/config.json ]]; then
if [[ -f ${{ inputs.configFile }} ]]; then
echo "has_config=true" >> $GITHUB_OUTPUT
else
echo "Pr-commands config file (.pr-commands/config.json) does not exist"
Expand All @@ -65,7 +70,7 @@ runs:
if: steps.config.outputs.has_config == 'true'
run: |
echo 'CONFIG_JSON<<EOF' >> $GITHUB_ENV
cat ./.pr-commands/config.json >> $GITHUB_ENV
cat ${{ inputs.configFile }} >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
shell: bash

Expand Down

0 comments on commit e91487c

Please sign in to comment.