shared-actions/inject-content
Michael Seele 9ab5db7b61
All checks were successful
validate-shared-actions / validate-shared-actions (pull_request) Successful in 40s
Aikido Security PR Check / Aikido Security Scan (pull_request) Successful in 52s
feat: add inject-content action
2026-05-05 12:23:18 +00:00
..
action.yml feat: add inject-content action 2026-05-05 12:23:18 +00:00
README.md feat: add inject-content action 2026-05-05 12:23:18 +00:00

inject-content

Inject content into a file by appending or overwriting. Useful for writing secrets, configuration snippets, or any multi-line content into an existing file at runtime.

Inputs

Input Required Default Description
content Yes Content to write into the target file
target-file Yes Path to the target file
mode No append Write mode: append adds to the end of the file; overwrite replaces its contents

Usage

Append secrets to a Java .properties file:

- uses: https://schmalz-git.git.onstackit.cloud/schmalz/shared-actions/inject-content@inject-content-v1
  with:
    content: ${{ secrets.APP_PROPERTIES }}
    target-file: src/main/resources/application.properties

Overwrite a .env file:

- uses: https://schmalz-git.git.onstackit.cloud/schmalz/shared-actions/inject-content@inject-content-v1
  with:
    content: ${{ secrets.DOTENV_CONTENT }}
    target-file: .env
    mode: overwrite

Notes

  • Content is passed via an environment variable to avoid shell injection vulnerabilities.
  • In append mode a blank line is inserted between existing content and the new content. If the target file is empty or does not exist, no leading blank line is added.
  • In overwrite mode the file is replaced entirely; if the file does not exist it is created.
  • Both modes ensure the written content ends with a trailing newline.
  • Parent directories of target-file are created automatically if they do not exist.