Add License Headers #54
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
# © 2023 Doriel Rivalet | |
# Use of this source code is governed by a MIT license that can be | |
# found in the LICENSE file. | |
name: Add License Headers | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * 0' # Run every Sunday at midnight UTC | |
jobs: | |
add-license-header: | |
runs-on: ubuntu-latest | |
name: Automatically add missing license headers | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Set up Git | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Check if commit was made by github-actions[bot] | |
id: check_last_commit_author | |
run: | | |
LAST_COMMIT_AUTHOR=$(git log -1 --format="%cn") | |
echo "Last commit author: $LAST_COMMIT_AUTHOR" | |
if [ "$LAST_COMMIT_AUTHOR" = "github-actions[bot]" ]; then | |
echo "Last commit was already made by github-actions[bot]. Cancelling the workflow." | |
exit 1 | |
fi | |
shell: bash | |
- name: Check License Header | |
uses: apache/skywalking-eyes/header@main # always prefer to use a revision instead of `main`. | |
# with: | |
# log: debug # optional: set the log level. The default value is `info`. | |
# config: .licenserc.yaml # optional: set the config file. The default value is `.licenserc.yaml`. | |
# token: # optional: the token that license eye uses when it needs to comment on the pull request. Set to empty ("") to disable commenting on pull request. The default value is ${{ github.token }} | |
# mode: # optional: Which mode License-Eye should be run in. Choices are `check` or `fix`. The default value is `check`. | |
with: | |
mode: fix | |
- name: Check Dependencies' License | |
uses: apache/skywalking-eyes/dependency@main # always prefer to use a revision instead of `main`. | |
# with: | |
# log: debug # optional: set the log level. The default value is `info`. | |
# config: .licenserc.yaml # optional: set the config file. The default value is `.licenserc.yaml`. | |
# mode: # optional: Which mode License-Eye should be run in. Choices are `check` or `resolve`. The default value is `check`. | |
# flags: # optional: Extra flags appended to the command, for example, `--summary=path/to/template.tmpl` | |
with: | |
mode: resolve | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
commit-message: 'style(bot): add missing license headers' | |
title: 'Add license headers' | |
reviewers: DorielRivalet | |
branch: create-pull-request/add-license-headers | |
add-paths: | | |
./ |