Update License Year #27
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 License Year | |
on: | |
schedule: | |
- cron: "0 0 1 1 *" # 毎年1月1日に実行 | |
workflow_dispatch: | |
push: | |
branches: | |
- "feature/refactor**" | |
jobs: | |
commit-changes: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate GitHub App Token | |
id: app_token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.GHA_APP_ID }} | |
private-key: ${{ secrets.GHA_PRIVATE_KEY }} | |
owner: ${{ github.repository_owner }} | |
- name: Make changes (e.g., update LICENSE year) | |
run: | | |
current_year=$(date +"%Y") | |
echo "current_year=$current_year" >> $GITHUB_ENV | |
sed -i "s/[0-9]\{4\}/$current_year/g" LICENSE | |
- name: Configure Git | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Create new branch | |
run: | | |
branch_name="update-license-year-$current_year" | |
git checkout -b "$branch_name" | |
- name: Commit changes | |
id: commit_changes | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
git add LICENSE | |
git commit -m "Update License year to $current_year" | |
echo "changes_made=true" >> "$GITHUB_ENV" | |
else | |
echo "No changes to commit" | |
echo "changes_made=false" >> "$GITHUB_ENV" | |
fi | |
- name: Create Pull Request | |
if: env.changes_made == 'true' | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: "Update License year to $current_year" | |
title: "Update License year to $current_year" | |
body: "This PR updates the LICENSE year to $current_year." | |
branch: ${{ env.branch_name }} | |
base: main | |
labels: "auto-merge" | |
reviewers: "octocat" | |
assignees: "octocat" | |
draft: false | |
branch-suffix: timestamp |