Set Date #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Set Date | |
# Run once every day | |
# If we run it on schedule, but only change the date stamp if the repo has changed, The date could be behind by up to a day. | |
# We can't really try to change it with every push the way workflows are set up now, | |
# because there is no way to control which workflows run first, so some builds will not have the updated date and will lag behind by one build. | |
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token | |
# "When you use the repository's GITHUB_TOKEN to perform tasks on behalf of the GitHub Actions app, | |
# events triggered by the GITHUB_TOKEN will not create a new workflow run." | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
update-date: | |
runs-on: ubuntu-latest | |
if: ${{ github.repository == 'rusefi/rusefi' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Check last date | |
run: | | |
export RECENT_GIT_MESSAGE="$(git log -1 --pretty=%B)" | |
export RECENT_GIT_MESSAGE_11="${RECENT_GIT_MESSAGE:0:11}" | |
echo "RECENT_GIT_MESSAGE=[$RECENT_GIT_MESSAGE] RECENT_GIT_MESSAGE_11=[${RECENT_GIT_MESSAGE_11}]" | |
if [ "$(RECENT_GIT_MESSAGE_11)" = "Update date" ]; then echo "skip=true" >> $GITHUB_ENV; fi | |
- name: Install Tools | |
if: ${{ env.skip != 'true' }} | |
run: | | |
sudo bash misc/actions/add-ubuntu-latest-apt-mirrors.sh | |
sudo apt-get install subversion | |
- name: Write Date File | |
if: ${{ env.skip != 'true' }} | |
run: | | |
echo -e -n "#pragma once\n#define VCS_DATE $(date "+%Y%m%d")\n" > ./firmware/controllers/date_stamp.h | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub set-date Action" | |
git commit -m "Update date" -a 2>&1 | grep -E '(nothing to commit|changed)' | |
git stash | |
git pull --rebase | |
- name: Push changed date file | |
if: ${{ env.skip != 'true' }} | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ github.token }} | |
branch: master |