Skip to content

jaywcjlove/github-action-modify-file-content

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Modify File Content

Buy me a coffee test

Replace text content and submit content

Here is the example: update time 2024-06-25 15:56:51

Here is the different delimiter example: different GAMFC_TABEL & GAMFC_TABEL-END (test)

Inputs

  • token Your GITHUB_TOKEN. This is required. Why do we need token? Read more here: About the GITHUB_TOKEN secret. Default: ${{ github.token }}
  • body what needs to be replaced
  • path file to be replaced
  • branch The branch where the files are committed. Default: ${{ github.ref_name }}
  • ref The name of the commit/branch/tag. Default: the repository’s default branch (usually master)
  • overwrite Overwrite the entire file content, by default false
  • sync_local_file Sync local file content, by default true
  • message The commit message. by default doc: update <file path>.
  • committer_name The name of the author or committer of the commit. by default github-actions[bot]
  • committer_email The email of the author or committer of the commit. by default github-actions[bot]@users.noreply.github.com
  • openDelimiter Character to use for opening delimiter, by default "<!--GAMFC-->"
  • closeDelimiter Character to use for closing delimiter, by default "<!--GAMFC-END-->"

Outputs

  • content text file content

Example Usage

- name: Modify README.md
  uses: jaywcjlove/github-action-modify-file-content@main
  with:
    path: README.md

README.md file content

update time <!--GAMFC-->2024-06-25 15:56:51<!--GAMFC-END-->

Replace the content between <!--GAMFC-->2024-06-25 15:56:51<!--GAMFC-END-->.

format date

- name: Modify README.md
  uses: jaywcjlove/github-action-modify-file-content@main
  with:
    path: README.md
    body: "{{date:YYYY-MM-DD HH:mm:ss}}"

overwrite file

- name: Modify README.md
  uses: jaywcjlove/github-action-modify-file-content@main
  with:
    path: README.md
    body: "overwrite file content {{date:YYYY-MM-DD HH:mm:ss}}",
    overwrite: 'true'

specify branch changes

- name: Modify test test/overwrite.file.md
  uses: jaywcjlove/github-action-modify-file-content@main
  with:
    branch: test
    path: test/overwrite.file.md
    body: "{{date:YYYY-MM-DD HH:mm:ss}}"
    overwrite: 'true'

See Also

License

Licensed under the MIT License.