Skip to content

ci/cd: update date in data file added. #1

ci/cd: update date in data file added.

ci/cd: update date in data file added. #1

Workflow file for this run

name: Update Date in data.json
on:
push:
branches:
- main
jobs:
update-date:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update date in data.json
run: |
current_date=$(date +'%Y.%-m.%-d')
sed -i 's/"date": "[0-9]\{4\}\.[0-9]\{1,2\}\.[0-9]\{1,2\}"/"date": "'"$current_date"'"/' docs/data.json
- name: Commit and push if changed
run: |
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
git add docs/data.json
git diff --quiet && git diff --staged --quiet || (git commit -m "Update date in data.json" && git push)