diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b00bc956..79ddcaf1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,4 +67,8 @@ cat my-token.txt | podman secret create repo-secret - ```bash podman run --entrypoint /entrypoint.sh --secret repo-secret,type=env,target=GITHUB_TOKEN --env-file=envfile -v my-trestle-space:/data -w /data localhost:5000/trestlebot:latest -``` \ No newline at end of file +``` + +### Adding a new action + +First, create an entrypoint script for the new action in the `trestlebot/infra` directory. Then add the action by creating a new directory in the `actions` directory with an `action.yml` that references your new entrypoint. \ No newline at end of file diff --git a/actions/trestle-bot/action.yml b/actions/trestle-bot/action.yml new file mode 100644 index 00000000..f94013b3 --- /dev/null +++ b/actions/trestle-bot/action.yml @@ -0,0 +1,91 @@ +name: "trestle-bot" +author: "Red Hat Product Security" +description: "A workflow automation manager for OSCAL formatted compliance content" + +inputs: + markdown_path: + description: Path relative to the repository path where the Trestle markdown files are located. See project README.md for more information. + required: true + oscal_model: + description: OSCAL Model type to assemble. Values can be catalog, profile, compdef, or ssp. + required: true + check_only: + description: "Runs tasks and exits with an error if there is a diff. Defaults to false" + required: false + default: "false" + github_token: + description: "GitHub token used to make authenticated API requests" + required: false + skip_assemble: + description: "Skip assembly task. Defaults to false" + required: false + default: "false" + skip_regenerate: + description: "Skip regenerate task. Defaults to false." + required: false + default: "false" + skip_items: + 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_path: + description: Path relative to the repository path where the ssp index is located. See project README.md for information about the ssp index. + required: false + default: "ssp-index.json" + commit_message: + 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 + default: ${{ github.ref_name }} + target_branch: + description: 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. + required: false + file_pattern: + description: Comma separated file pattern list used for `git add`. For example `component-definitions/*,*json`. Defaults to (`.`) + required: false + default: '.' + repository: + description: Local file path to the git repository. Defaults to the current directory (`.`) + required: false + default: '.' + commit_user_name: + description: Name used for the commit user + required: false + default: github-actions[bot] + commit_user_email: + description: Email address used for the commit user + required: false + default: 41898282+github-actions[bot]@users.noreply.github.com + commit_author_name: + description: Name used for the commit author. Defaults to the username of whoever triggered this workflow run. + required: false + default: ${{ github.actor }} + commit_author_email: + description: Email address used for the commit author. Defaults to the email of whoever triggered this workflow run. + required: false + default: ${{ github.actor }}@users.noreply.github.com + +outputs: + changes: + description: Value is "true" if changes were committed back to the repository. + commit: + description: Full hash of the created commit. Only present if the "changes" output is "true". + pr_number: + description: Number of the submitted pull request. Only present if a pull request is submitted. + +runs: + using: "docker" + image: "Dockerfile" + entrypoint: "/entrypoint.sh" + env: + GITHUB_TOKEN: ${{ inputs.github_token }} + +branding: + icon: "check" + color: "green" diff --git a/trestlebot/infra/entrypoints/create.py b/trestlebot/infra/entrypoints/create.py new file mode 100644 index 00000000..fa2c70f3 --- /dev/null +++ b/trestlebot/infra/entrypoints/create.py @@ -0,0 +1,31 @@ +# Copyright 2023 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Create OSCAL content.""" + +import sys + + +def create_entrypoint(): + """Creates specified OSCAL formatted content.""" + pass + + +def main(): + + return create_entrypoint() + + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file