From 61bd7d65648113e5cf1777d652fba49bb836c321 Mon Sep 17 00:00:00 2001 From: Samir M Date: Thu, 24 Oct 2024 13:50:00 +0200 Subject: [PATCH] BUILD-6701 Update license and add automated way of updating --- .github/workflows/update-license.yml | 53 +++++++++++++++++++ .../licenses/sonarsource.txt | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update-license.yml diff --git a/.github/workflows/update-license.yml b/.github/workflows/update-license.yml new file mode 100644 index 0000000..639133f --- /dev/null +++ b/.github/workflows/update-license.yml @@ -0,0 +1,53 @@ +name: Update SonarSource License + +on: + push: + schedule: + - cron: '0 0 1 1 *' # At 00:00 on January 1st every year + +permissions: + contents: write + pull-requests: write + +jobs: + update-license: + runs-on: ubuntu-latest + + steps: + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y-%m-%d')" + + - name: Print current year + run: | + echo "Current Year: $(date +'%Y')" + + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Update license year + run: | + ls -l + pwd + FILE_PATH="{{cookiecutter.repository_name}}/licenses/sonarsource.txt" + cat $FILE_PATH + sed -i "s/2014-[0-9]\{4\}/2014-$(date +'%Y')/" $FILE_PATH + cat $FILE_PATH + + - name: Commit changes + run: | + git config --global user.name 'sonartech' + git config --global user.email 'sonartech@sonarsource.com' + git checkout -b feat/bot/update-license-year + git add . + git commit -m "Update SonarSource license year to $(date +'%Y')" + git push --set-upstream origin feat/bot/update-license-year + + - name: Create Pull Request + uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.5.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: feat/bot/update-license-year + title: "Update SonarSource license year to $(date +'%Y')" + body: "This PR updates the SonarSource license year to $(date +'%Y')." + base: master diff --git a/{{cookiecutter.repository_name}}/licenses/sonarsource.txt b/{{cookiecutter.repository_name}}/licenses/sonarsource.txt index 616cadf..3e433a4 100644 --- a/{{cookiecutter.repository_name}}/licenses/sonarsource.txt +++ b/{{cookiecutter.repository_name}}/licenses/sonarsource.txt @@ -1,3 +1,3 @@ -Copyright (C) SonarSource SA +Copyright (C) 2014-2023 SonarSource SA All rights reserved mailto:info AT sonarsource DOT com