Skip to content

Commit

Permalink
chore: update actions for debug and config options
Browse files Browse the repository at this point in the history
  • Loading branch information
qduanmu committed Dec 13, 2024
1 parent 9a9c37c commit 1f16ca3
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 62 deletions.
2 changes: 1 addition & 1 deletion actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This document provides instructions and examples for creating and using GitHub A
## Directory Structure

- Actions related to trestle-bot are located in the `actions` directory.
- Actions should correlate an command under the `trestlebot/cli/commands` directory.
- Actions should correlate a command under the `trestlebot/cli/commands` directory.

## Adding a New Action

Expand Down
8 changes: 4 additions & 4 deletions actions/autosync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ name: Example Workflow
| skip_assemble | Skip assembly task. Defaults to false | false | False |
| skip_regenerate | Skip regenerate task. Defaults to false. | false | False |
| skip_items | Comma-separated glob patterns list of content by trestle name to skip during task execution. For example `profile_x,profile_y*,`. | None | False |
| ssp_index_file | Path relative to the repository path where the ssp index is located. See action README.md for information about the ssp index. | ssp-index.json | False |
| ssp_index_file | JSON file relative to the repository path where the ssp index is located. See action README.md for information about the ssp index. | ssp-index.json | False |
| commit_message | Custom commit message | Sync automatic updates | False |
| pull_request_title | Custom pull request title | Automatic updates from trestlebot | False |
| branch | Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event. | ${{ github.ref_name }} | False |
| target_branch | Target branch (or base branch) to create a pull request against. If unset, no pull request will be created. If set, a pull request will be created using the `branch` field as the head branch. | None | False |
| file_patterns | Comma separated file pattern list used for `git add`. For example `component-definitions/*,*json`. Defaults to (`.`) | . | False |
Expand All @@ -42,7 +41,8 @@ name: Example Workflow
| commit_user_email | Email address used for the commit user | 41898282+github-actions[bot]@users.noreply.github.com | False |
| commit_author_name | Name used for the commit author. Defaults to the username of whoever triggered this workflow run. | ${{ github.actor }} | False |
| commit_author_email | Email address used for the commit author. | ${{ github.actor }}@users.noreply.github.com | False |
| verbose | Enable verbose logging | false | False |
| debug | Enable debug logging messages. | false | False |
| config | Path to trestlebot configuration file. | .trestlebot/config.yml | False |

<!-- END_ACTION_INPUTS -->

Expand All @@ -60,7 +60,7 @@ name: Example Workflow
### Additional information on workflow inputs

- `markdown_dir`: This is the location for Markdown generated by the `trestle author <model>-generate` commands
- `ssp_index_file`: This is a text file that stores the component definition information by name in trestle with the ssp name. Example below
- `ssp_index_file`: This is a JSON file that stores the component definition information by name in trestle with the ssp name. Example below

```json
"ssp1": {
Expand Down
14 changes: 7 additions & 7 deletions actions/autosync/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@ inputs:
description: "Comma-separated glob patterns list of content by trestle name to skip during task execution. For example `profile_x,profile_y*,`."
required: false
ssp_index_file:
description: Path relative to the repository path where the ssp index is located. See action README.md for information about the ssp index.
description: JSON file relative to the repository path where the ssp index is located. See action README.md for information about the ssp index.
required: false
default: "ssp-index.json"
commit_message:
description: Custom commit message
required: false
default: "Sync automatic updates"
pull_request_title:
description: Custom pull request title
required: false
default: "Automatic updates from trestlebot"
branch:
description: Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event.
required: false
Expand Down Expand Up @@ -75,10 +71,14 @@ inputs:
description: Email address used for the commit author.
required: false
default: ${{ github.actor }}@users.noreply.github.com
verbose:
description: Enable verbose logging
debug:
description: Enable debug logging messages.
required: false
default: "false"
config:
description: Path to trestlebot configuration file.
required: false
default: ".trestlebot/config.yml"

outputs:
changes:
Expand Down
8 changes: 4 additions & 4 deletions actions/autosync/auto-sync-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ command="trestlebot autosync \
--oscal-model=\"${INPUT_OSCAL_MODEL}\" \
--ssp-index-file=\"${INPUT_SSP_INDEX_FILE}\" \
--commit-message=\"${INPUT_COMMIT_MESSAGE}\" \
--pull-request-title=\"${INPUT_PULL_REQUEST_TITLE}\" \
--branch=\"${INPUT_BRANCH}\" \
--file-patterns=\"${INPUT_FILE_PATTERNS}\" \
--committer-name=\"${INPUT_COMMIT_USER_NAME}\" \
Expand All @@ -23,7 +22,8 @@ command="trestlebot autosync \
--repo-path=\"${INPUT_REPO_PATH}\" \
--target-branch=\"${INPUT_TARGET_BRANCH}\" \
--skip-items=\"${INPUT_SKIP_ITEMS}\" \
--version=\"${INPUT_VERSION}\""
--version=\"${INPUT_VERSION}\"
--config=\"${INPUT_CONFIG}\""

# Conditionally include flags
if [[ ${INPUT_SKIP_ASSEMBLE} == true ]]; then
Expand All @@ -38,8 +38,8 @@ if [[ ${INPUT_DRY_RUN} == true ]]; then
command+=" --dry-run"
fi

if [[ ${INPUT_VERBOSE} == true ]]; then
command+=" --verbose"
if [[ ${INPUT_DEBUG} == true ]]; then
command+=" --debug"
fi

eval "${command}"
4 changes: 2 additions & 2 deletions actions/create-cd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ name: Example Workflow
| dry_run | Runs tasks without pushing changes to the repository. | false | False |
| github_token | "GitHub token used to make authenticated API requests. Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token." | None | False |
| commit_message | Commit message | Sync automatic updates | False |
| pull_request_title | Custom pull request title | Automatic updates from trestlebot | False |
| branch | Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event. | ${{ github.ref_name }} | False |
| target_branch | Target branch (or base branch) to create a pull request against. If unset, no pull request will be created. If set, a pull request will be created using the `branch` field as the head branch. | None | False |
| file_patterns | Comma separated file pattern list used for `git add`. For example `component-definitions/*,*json`. Defaults to (`.`) | . | False |
Expand All @@ -44,7 +43,8 @@ name: Example Workflow
| commit_user_email | Email address used for the commit user | 41898282+github-actions[bot]@users.noreply.github.com | False |
| commit_author_name | Name used for the commit author. Defaults to the username of whoever triggered this workflow run. | ${{ github.actor }} | False |
| commit_author_email | Email address used for the commit author. | ${{ github.actor }}@users.noreply.github.com | False |
| verbose | Enable verbose logging | false | False |
| debug | Enable debug logging messages. | false | False |
| config | Path to trestlebot configuration file. | .trestlebot/config.yml | False |

<!-- END_ACTION_INPUTS -->

Expand Down
12 changes: 6 additions & 6 deletions actions/create-cd/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ inputs:
description: Commit message
required: false
default: "Sync automatic updates"
pull_request_title:
description: Custom pull request title
required: false
default: "Automatic updates from trestlebot"
branch:
description: Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event.
required: false
Expand Down Expand Up @@ -73,10 +69,14 @@ inputs:
description: Email address used for the commit author.
required: false
default: ${{ github.actor }}@users.noreply.github.com
verbose:
description: Enable verbose logging
debug:
description: Enable debug logging messages.
required: false
default: "false"
config:
description: Path to trestlebot configuration file.
required: false
default: ".trestlebot/config.yml"

outputs:
changes:
Expand Down
12 changes: 6 additions & 6 deletions actions/create-cd/create-cd-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ command="trestlebot create compdef \
--markdown-dir=\"${INPUT_MARKDOWN_DIR}\" \
--commit-message=\"${INPUT_COMMIT_MESSAGE}\" \
--filter-by-profile=\"${INPUT_FILTER_BY_PROFILE}\" \
--pull-request-title=\"${INPUT_PULL_REQUEST_TITLE}\" \
--branch=\"${INPUT_BRANCH}\" \
--file-patterns=\"${INPUT_FILE_PATTERNS}\" \
--committer-name=\"${INPUT_COMMIT_USER_NAME}\" \
--committer-email=\"${INPUT_COMMIT_USER_EMAIL}\" \
--author-name=\"${INPUT_COMMIT_AUTHOR_NAME}\" \
--author-email=\"${INPUT_COMMIT_AUTHOR_EMAIL}\" \
--repo-path=\"${INPUT_REPO_PATH}\" \
--target-branch=\"${INPUT_TARGET_BRANCH}\""
--target-branch=\"${INPUT_TARGET_BRANCH}\"
--config=\"${INPUT_CONFIG}\""

# Conditionally include flags
if [[ ${INPUT_VERBOSE} == true ]]; then
command+=" --verbose"
fi

if [[ ${INPUT_DRY_RUN} == true ]]; then
command+=" --dry-run"
fi

if [[ ${INPUT_DEBUG} == true ]]; then
command+=" --debug"
fi

eval "${command}"
8 changes: 4 additions & 4 deletions actions/rules-transform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ With custom rules directory:
uses: RedHatProductSecurity/trestle-bot/actions/rules-transform@main
with:
markdown_dir: "markdown/components"
rules_view_path: "custom-rules-dir/"
rules_view_dir: "custom-rules-dir/"
```
## Action Inputs
Expand All @@ -37,12 +37,11 @@ With custom rules directory:
| Name | Description | Default | Required |
| --- | --- | --- | --- |
| markdown_dir | Path relative to the repository path to create markdown files. See action README.md for more information. | None | True |
| rules_view_path | Path relative to the repository path where the Trestle rules view files are located. Defaults to `rules/`. | rules/ | False |
| rules_view_dir | Path relative to the repository path where the Trestle rules view files are located. Defaults to `rules/`. | rules/ | False |
| dry_run | Runs tasks without pushing changes to the repository. | false | False |
| github_token | "GitHub token used to make authenticated API requests. Note: You should use a defined secret like "secrets.GITHUB_TOKEN" in your workflow file, do not hardcode the token." | None | False |
| skip_items | Comma-separated glob patterns list of content by Trestle name to skip during task execution. For example `compdef_x,compdef_y*,`. | None | False |
| commit_message | Commit message | Sync automatic updates | False |
| pull_request_title | Custom pull request title | Automatic updates from trestlebot | False |
| branch | Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event. | ${{ github.ref_name }} | False |
| target_branch | Target branch (or base branch) to create a pull request against. If unset, no pull request will be created. If set, a pull request will be created using the `branch` field as the head branch. | None | False |
| file_patterns | Comma separated file pattern list used for `git add`. For example `component-definitions/*,*json`. Defaults to (`.`) | . | False |
Expand All @@ -51,7 +50,8 @@ With custom rules directory:
| commit_user_email | Email address used for the commit user | 41898282+github-actions[bot]@users.noreply.github.com | False |
| commit_author_name | Name used for the commit author. Defaults to the username of whoever triggered this workflow run. | ${{ github.actor }} | False |
| commit_author_email | Email address used for the commit author. | ${{ github.actor }}@users.noreply.github.com | False |
| verbose | Enable verbose logging | false | False |
| debug | Enable debug logging messages. | false | False |
| config | Path to trestlebot configuration file. | .trestlebot/config.yml | False |

<!-- END_ACTION_INPUTS -->

Expand Down
14 changes: 7 additions & 7 deletions actions/rules-transform/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
markdown_dir:
description: Path relative to the repository path to create markdown files. See action README.md for more information.
required: true
rules_view_path:
rules_view_dir:
description: Path relative to the repository path where the Trestle rules view files are located. Defaults to `rules/`.
required: false
default: "rules/"
Expand All @@ -26,10 +26,6 @@ inputs:
description: Commit message
required: false
default: "Sync automatic updates"
pull_request_title:
description: Custom pull request title
required: false
default: "Automatic updates from trestlebot"
branch:
description: Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event.
required: false
Expand Down Expand Up @@ -61,10 +57,14 @@ inputs:
description: Email address used for the commit author.
required: false
default: ${{ github.actor }}@users.noreply.github.com
verbose:
description: Enable verbose logging
debug:
description: Enable debug logging messages.
required: false
default: "false"
config:
description: Path to trestlebot configuration file.
required: false
default: ".trestlebot/config.yml"

outputs:
changes:
Expand Down
15 changes: 8 additions & 7 deletions actions/rules-transform/rules-transform-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ set_git_safe_directory
# Initialize the command variable
command="trestlebot rules-transform \
--markdown-dir=\"${INPUT_MARKDOWN_DIR}\" \
--rules-view-path=\"${INPUT_RULES_VIEW_PATH}\" \
--rules-view-dir=\"${INPUT_RULES_VIEW_DIR}\" \
--commit-message=\"${INPUT_COMMIT_MESSAGE}\" \
--pull-request-title=\"${INPUT_PULL_REQUEST_TITLE}\" \
--branch=\"${INPUT_BRANCH}\" \
--file-patterns=\"${INPUT_FILE_PATTERNS}\" \
--committer-name=\"${INPUT_COMMIT_USER_NAME}\" \
Expand All @@ -21,15 +20,17 @@ command="trestlebot rules-transform \
--author-email=\"${INPUT_COMMIT_AUTHOR_EMAIL}\" \
--repo-path=\"${INPUT_REPO_PATH}\" \
--target-branch=\"${INPUT_TARGET_BRANCH}\" \
--skip-items=\"${INPUT_SKIP_ITEMS}\""
--skip-items=\"${INPUT_SKIP_ITEMS}\"
--version=\"${INPUT_VERSION}\"
--config=\"${INPUT_CONFIG}\""

# Conditionally include flags
if [[ ${INPUT_VERBOSE} == true ]]; then
command+=" --verbose"
fi

if [[ ${INPUT_DRY_RUN} == true ]]; then
command+=" --dry-run"
fi

if [[ ${INPUT_DEBUG} == true ]]; then
command+=" --debug"
fi

eval "${command}"
4 changes: 2 additions & 2 deletions actions/sync-upstreams/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ name: Example Workflow
| exclude_models | Comma-separated glob pattern of model names (i.e. trestle directory name) to exclude from the sync. For example, `*framework-v1`. Defaults to skip no model names. | None | False |
| skip_validation | Skip validation of the upstream OSCAL content. Defaults to false | false | False |
| commit_message | Commit message | Sync automatic updates | False |
| pull_request_title | Custom pull request title | Automatic updates from trestlebot | False |
| branch | Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event. | ${{ github.ref_name }} | False |
| target_branch | Target branch (or base branch) to create a pull request against. If unset, no pull request will be created. If set, a pull request will be created using the `branch` field as the head branch. | None | False |
| file_patterns | Comma-separated file pattern list used for `git add`. For example `component-definitions/*,*json`. Defaults to (`.`) | . | False |
Expand All @@ -38,7 +37,8 @@ name: Example Workflow
| commit_user_email | Email address used for the commit user | 41898282+github-actions[bot]@users.noreply.github.com | False |
| commit_author_name | Name used for the commit author. Defaults to the username of whoever triggered this workflow run. | ${{ github.actor }} | False |
| commit_author_email | Email address used for the commit author. | ${{ github.actor }}@users.noreply.github.com | False |
| verbose | Enable verbose logging | false | False |
| debug | Enable debug logging messages. | false | False |
| config | Path to trestlebot configuration file. | .trestlebot/config.yml | False |

<!-- END_ACTION_INPUTS -->

Expand Down
12 changes: 6 additions & 6 deletions actions/sync-upstreams/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ inputs:
description: Commit message
required: false
default: "Sync automatic updates"
pull_request_title:
description: Custom pull request title
required: false
default: "Automatic updates from trestlebot"
branch:
description: Name of the Git branch to which modifications should be pushed. Required if Action is used on the `pull_request` event.
required: false
Expand Down Expand Up @@ -64,10 +60,14 @@ inputs:
description: Email address used for the commit author.
required: false
default: ${{ github.actor }}@users.noreply.github.com
verbose:
description: Enable verbose logging
debug:
description: Enable debug logging messages.
required: false
default: "false"
config:
description: Path to trestlebot configuration file.
required: false
default: ".trestlebot/config.yml"

outputs:
changes:
Expand Down
12 changes: 6 additions & 6 deletions actions/sync-upstreams/sync-upstreams-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ command="trestlebot sync-upstreams \
--include-models=\"${INPUT_INCLUDE_MODELS}\" \
--exclude-models=\"${INPUT_EXCLUDE_MODELS}\" \
--commit-message=\"${INPUT_COMMIT_MESSAGE}\" \
--pull-request-title=\"${INPUT_PULL_REQUEST_TITLE}\" \
--branch=\"${INPUT_BRANCH}\" \
--file-patterns=\"${INPUT_FILE_PATTERNS}\" \
--committer-name=\"${INPUT_COMMIT_USER_NAME}\" \
--committer-email=\"${INPUT_COMMIT_USER_EMAIL}\" \
--author-name=\"${INPUT_COMMIT_AUTHOR_NAME}\" \
--author-email=\"${INPUT_COMMIT_AUTHOR_EMAIL}\" \
--repo-path=\"${INPUT_REPO_PATH}\" \
--target-branch=\"${INPUT_TARGET_BRANCH}\""
--target-branch=\"${INPUT_TARGET_BRANCH}\"
--config=\"${INPUT_CONFIG}\""

# Conditionally include flags
if [[ ${INPUT_VERBOSE} == true ]]; then
command+=" --verbose"
if [[ ${INPUT_SKIP_VALIDATION} == true ]]; then
command+=" --skip-validation"
fi

if [[ ${INPUT_DRY_RUN} == true ]]; then
command+=" --dry-run"
fi

if [[ ${INPUT_SKIP_VALIDATION} == true ]]; then
command+=" --skip-validation"
if [[ ${INPUT_DEBUG} == true ]]; then
command+=" --debug"
fi

eval "${command}"

0 comments on commit 1f16ca3

Please sign in to comment.