From 9f85745ffad3a05fafec6a2d4384261e4b055a59 Mon Sep 17 00:00:00 2001 From: Hans Klunder Date: Sun, 11 Feb 2024 13:13:40 +0100 Subject: [PATCH] Add automatic license update --- .github/workflows/update-license-year.sh | 14 ++++++++++++++ .github/workflows/update-license-year.yml | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .github/workflows/update-license-year.sh create mode 100644 .github/workflows/update-license-year.yml diff --git a/.github/workflows/update-license-year.sh b/.github/workflows/update-license-year.sh new file mode 100644 index 0000000..ac20777 --- /dev/null +++ b/.github/workflows/update-license-year.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +license='LICENSE.txt' +prefix='2016-' +current_year=$(date +%Y) +sed -i -e "s/$prefix\([0-9\]\+\)/$prefix$current_year/" $license + +if [ "$(git diff $license)" ]; then + git add $license + git commit -m "Update license year to $current_year" + git push +else + echo "No changes detected in $license" +fi \ No newline at end of file diff --git a/.github/workflows/update-license-year.yml b/.github/workflows/update-license-year.yml new file mode 100644 index 0000000..a7373d7 --- /dev/null +++ b/.github/workflows/update-license-year.yml @@ -0,0 +1,13 @@ +name: Update License Year + +on: + schedule: + - cron: '5 12 1 1 *' + +jobs: + update_license: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Update license year + run: ./update_license.sh \ No newline at end of file