Giter VIP home page Giter VIP logo

github-action-modify-file-content's Introduction

Modify File Content

Buy me a coffee test

Replace text content and submit content

Here is the example: update time 2024-03-07 17:17:45

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-03-07 17:17:45<!--GAMFC-END-->

Replace the content between <!--GAMFC-->2024-03-07 17:17:45<!--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.

github-action-modify-file-content's People

Contributors

github-actions[bot] avatar jaywcjlove avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

emily-thomas

github-action-modify-file-content's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • peaceiris/actions-gh-pages v3
.github/workflows/issue.yml
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • @actions/core ~1.10.0
  • @actions/github ~6.0.0
  • @uiw/formatter ~2.0.1
  • fs-extra ~11.2.0
  • @kkt/ncc ~1.1.1
  • husky ^9.0.11
  • lint-staged ^15.2.2
  • node >=v20.11.0
  • npm >=10.2.4

  • Check this box to trigger a request for Renovate to run again on this repository

How to use VARIABLES for body content?

Hello, I tried using a variable to update a section in a README file but it was returned as is.

- name: Update section in readme
      run: 
      SECTION_DETAILS="This is a test content"
      uses: jaywcjlove/github-action-modify-file-content@main
      with:
        path: README.md
        body: "$SECTION_DETAILS"
        openDelimiter: "<!-- start-section -->"
        closeDelimiter: "<!-- end-section -->" 

The file is updated but this is what I see:

<!-- start-section -->
$SECTION_DETAILS
<!-- end-section -->

How can I exactly update the file using variables?

Request to Make Options to pass SHA/Ref

Is it possible to have this extended to pass in a SHA or Ref instead of defaulting to the default branch? I would like to use this to make a commit not to my master, but to a designated branch so that I can generate a PR into my master branch.

Please suggest if this is already possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.