Skip to content

Commit

Permalink
BUILD-6701 Update license and add automated way of updating
Browse files Browse the repository at this point in the history
  • Loading branch information
SamirM-BE committed Oct 24, 2024
1 parent 319cd17 commit 89054f8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/update-license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Update SonarSource License

on:
push:
schedule:
# - cron: '0 0 1 1 *' # At 00:00 on January 1st every year
- cron: '*/5 * * * *' # Every 5 minutes for testing purposes

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
2 changes: 1 addition & 1 deletion {{cookiecutter.repository_name}}/licenses/sonarsource.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Copyright (C) SonarSource SA
Copyright (C) 2014-2023 SonarSource SA
All rights reserved
mailto:info AT sonarsource DOT com

0 comments on commit 89054f8

Please sign in to comment.