Workflow to write the date, once a day (#1504)

* Add date workflow

* add files

* use VCS_DATE in engine controller

* initial values

* switched to using one file

* moved to controllers

* Add comment and fix cron entry

* add pragma once

* Add more comments
This commit is contained in:
David Holdeman 2020-06-17 09:59:57 -07:00 committed by GitHub
parent 6adc1eea1b
commit 664ed149f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 1 deletions

34
.github/workflows/set-date.yaml vendored Normal file
View File

@ -0,0 +1,34 @@
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 * * *'
jobs:
update-date:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Write Date File
run: |
echo -e -n "#pragma once\n#ifndef VCS_DATE\n#define VCS_DATE $(date "+%Y%m%d")\n#endif" > ./firmware/controllers/date_stamp.h
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m "Update date" -a 2>&1 | grep -E '(nothing to commit|changed)'
- name: Push changed date file
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
branch: master

View File

@ -0,0 +1,3 @@
#ifndef VCS_DATE
#define VCS_DATE 20200617
#endif

View File

@ -56,6 +56,7 @@
#include "launch_control.h"
#include "tachometer.h"
#include "gppwm.h"
#include "date_stamp.h"
#if EFI_SENSOR_CHART
#include "sensor_chart.h"
@ -716,6 +717,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20200614;
return VCS_DATE;
}
#endif /* EFI_UNIT_TEST */