Skip to content

Okay, so it must be the *... #12

Okay, so it must be the *...

Okay, so it must be the *... #12

Workflow file for this run

# There is one particular test for the Squiz/FileComment sniff which every year requires
# an update to the year used in a `@copyright` tag to allow the tests to keep passing.
# This workflow will automatically create a PR to the repo to handle this update.
name: "Update Squiz/FileComment Test"
on:
# Run every year on Jan 1st at 00:05.
schedule:
- cron: '5 0 1 1 *'
# And whenever this workflow is updated.
push:
paths:
- '.github/workflows/happy-new-year.yml'
pull_request:
paths:
- '.github/workflows/happy-new-year.yml'
# Also allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update-year-in-test:
runs-on: ubuntu-latest
# Don't run the cron job on forks.
if: ${{ github.event_name != 'schedule' || github.repository == 'PHPCSStandards/PHP_CodeSniffer' }}
name: "Happy New Year"
steps:
- name: Set branches to use
id: branches
run: |
echo "BASE=master" >> $GITHUB_OUTPUT
echo "PR_BRANCH=feature/squiz-filecomment-update-copyright-year" >> $GITHUB_OUTPUT
# Using "Tomorrow" to prevent accidentally getting last year if the server is not using UTC.
- name: Grab the new year
id: year
run: |
echo "NEW_YEAR=$(date --date="tomorrow" -u "+%Y")" >> $GITHUB_OUTPUT
- name: Show year
run: "echo current year: ${{ steps.year.outputs.NEW_YEAR }}"
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ steps.branches.outputs.BASE }}
- name: Update the year in the copyright tag in the fixed file
id: findreplace
uses: jacobtomlinson/gha-find-replace@v3
with:
find: '\* @copyright 20[0-9]{2} Squiz Pty Ltd'
# replace: "* @copyright ${{ steps.year.outputs.NEW_YEAR }} Squiz Pty Ltd"
replace: "* @copyright ${{ steps.year.outputs.NEW_YEAR }} Squiz Pty Ltd"
include: "src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.*.fixed"
regex: true
- name: Show number of modified files
run: "echo modified files: ${{ steps.findreplace.outputs.modifiedFiles }}"
- name: "Debug info: Show git status"
run: git status -vv --untracked=all
# - name: Create pull request
# uses: peter-evans/create-pull-request@v5
# with:
# base: ${{ steps.branches.outputs.BASE }}
# branch: ${{ steps.branches.outputs.PR_BRANCH }}
# delete-branch: true
# commit-message: "Squiz/FileComment: update year in test case fixed file"
# title: "Squiz/FileComment: update year in test case fixed file"
# yamllint disable rule:line-length
# body: |
# The regular annual update to make sure the build still passes ;-)
# Happy new year!
# This PR is auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request) using the [`happy-new-year.yml` workflow](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/.github/workflows/happy-new-year.yml).
# yamllint enable rule:line-length
# labels: |
# Type: chores/QA
# reviewers: |
# jrfnl