jaywcjlove / github-action-modify-file-content

Replace text content and submit content

Home Page:https://jaywcjlove.github.io/github-action-modify-file-content

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request to Make Options to pass SHA/Ref

Emily-Thomas opened this issue · comments

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.

I added ref input parameter.
@Emily-Thomas

Thank you so much, I will test this out and let you know.

@jaywcjlove I am trying to use this but am getting the error [PATH] does not match [sha] after modifyPathContents Body: runs

Potentially related to this? octokit/octokit.rb#581 I think it is a github error bubbling up when trying to make the commit and the SHA is not accurate.

Here is a copy of my setup.

    - name: New Branch
      uses: peterjgrainger/action-create-branch@v2.2.0
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        branch: 'var-${{ steps.date.outputs.date }}'
        sha: '${{ github.event.pull_request.head.sha }}'
    - uses: actions/checkout@v3
      with:
        ref: 'var-${{ steps.date.outputs.date }}'
    - name: Modify Conf
      uses: jaywcjlove/github-action-modify-file-content@main
      with:
        path: file.conf
        body: ${{ steps.getdata.outputs.data }}
        ref: 'var-${{ steps.date.outputs.date }}'

@Emily-Thomas

specify branch changes

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

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

Okay, I updated to use that format. Now the logging is correct in the action workflow, but the commit that is made is an empty commit. I've tried a few combinations of using path + ref, only path, only ref, using overwrite/not using overwrite and the result is the same, an empty commit. However when I go through the logging of the function, it is grabbing the right tag in the file and replacing it - just not saving or commiting those changes. @jaywcjlove - I appreciate the timely help and changes here.

Your latest changes work for me. Thanks for being so responsive to my issues. I was able to implement this action into my codebase successfully.