BUILD-6701 Update license and add automated way of updating #7
Workflow file for this run
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: 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 |