EndBug / add-and-commit

:octocat: Automatically commit changes made in your workflow run directly to your repo
MIT License
1.15k stars 117 forks source link

How to add current datetime in commit message? #648

Closed hero closed 4 months ago

hero commented 4 months ago

Just like I did in my bash shell:

git commit -m "Updated at `date '+%Y-%m-%d %H:%M:%S'`⚡️"

But I've tried, add-and-commit@v9.1.4 commit the orignal strings, which was NOT I want.

hero commented 4 months ago

Okay, I solved this problem myself, the Github Actions command is as follows:

- name: Get the current date time
  id: datetime
  run: echo "time_now=$(date '+%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT

- name: Add & Commit
  uses: EndBug/add-and-commit@v9.1.4
  with:          
      message: "Updated at ${{ steps.datetime.outputs.time_now}} ⚡️"