Update copyright dates #3
This file contains hidden or 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 copyright dates | |
| on: | |
| schedule: | |
| # Run every first day of the year at 09:00 AM UTC | |
| - cron: '0 9 1 1 *' | |
| workflow_dispatch: | |
| # Allow manual triggering | |
| jobs: | |
| update-copyright-dates: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| BASE_BRANCH: ${{ github.event.repository.default_branch }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.x' | |
| - name: Install bdip-tools | |
| run: pip install --extra-index-url https://maven.sing-group.org/repository/python-snapshots/simple/ bdip-tools | |
| - name: Git config | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Prepare branch | |
| run: | | |
| YEAR=$(date +%Y) | |
| BASE="${BASE_BRANCH:-master}" | |
| BRANCH="maintenance/update-copyright-dates-${YEAR}" | |
| git fetch origin "$BASE" | |
| git switch "$BASE" | |
| git branch -D "$BRANCH" 2>/dev/null || true | |
| PRE_SHA=$(git rev-parse --verify "$BRANCH" 2>/dev/null || echo "none") | |
| echo "YEAR=$YEAR" >> "$GITHUB_ENV" | |
| echo "BASE=$BASE" >> "$GITHUB_ENV" | |
| echo "BRANCH=$BRANCH" >> "$GITHUB_ENV" | |
| echo "PRE_SHA=$PRE_SHA" >> "$GITHUB_ENV" | |
| - name: Update copyright dates | |
| run: | | |
| bdip update-copyright-dates \ | |
| --dockerfiles-dir . \ | |
| --git \ | |
| --create-branch \ | |
| --push | |
| - name: Detect commit | |
| id: detect | |
| run: | | |
| POST_SHA=$(git rev-parse --verify "$BRANCH" 2>/dev/null || echo "none") | |
| if [ "$POST_SHA" != "none" ] && [ "$POST_SHA" != "$PRE_SHA" ]; then | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create Pull Request | |
| if: steps.detect.outputs.has_changes == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh pr create \ | |
| --title "Update copyright dates to $YEAR" \ | |
| --body "This PR updates the copyright dates to $YEAR." \ | |
| --base "$BASE" \ | |
| --head "$BRANCH" \ | |
| --label "maintenance" |