Skip to content

Commit 350bf3f

Browse files
committed
Automate copyright update
1 parent 4a73495 commit 350bf3f

File tree

4 files changed

+69
-16
lines changed

4 files changed

+69
-16
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Copyright
2+
3+
on:
4+
schedule:
5+
# Runs "At 08:00 on day-of-month 1 in January"
6+
- cron: '0 8 1 1 *'
7+
8+
workflow_dispatch:
9+
10+
env:
11+
HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI
12+
13+
jobs:
14+
copyright:
15+
name: Copyright
16+
runs-on: macos-13
17+
steps:
18+
- uses: actions/[email protected]
19+
- uses: ./.github/actions/ruby-cache
20+
- run: bundle exec fastlane copyright
21+
timeout-minutes: 5
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }}
24+
- uses: 8398a7/action-slack@v3
25+
with:
26+
status: ${{ job.status }}
27+
text: "You shall not pass!"
28+
job_name: "${{ github.workflow }}: ${{ github.job }}"
29+
fields: message,commit,author,action,workflow,job,took
30+
env:
31+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
32+
MATRIX_CONTEXT: ${{ toJson(matrix) }}
33+
if: failure()

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ GEM
200200
fastlane
201201
pry
202202
fastlane-plugin-sonarcloud_metric_kit (0.2.1)
203-
fastlane-plugin-stream_actions (0.3.20)
203+
fastlane-plugin-stream_actions (0.3.28)
204204
xctest_list (= 1.2.1)
205205
fastlane-plugin-versioning (0.5.2)
206206
ffi (1.16.3)
@@ -417,7 +417,7 @@ DEPENDENCIES
417417
fastlane-plugin-emerge
418418
fastlane-plugin-lizard
419419
fastlane-plugin-sonarcloud_metric_kit
420-
fastlane-plugin-stream_actions (= 0.3.20)
420+
fastlane-plugin-stream_actions (= 0.3.28)
421421
fastlane-plugin-versioning
422422
jazzy
423423
json

fastlane/Fastfile

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ source_packages_path = 'spm_cache'
1616
buildcache_xcargs = 'CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++'
1717
is_localhost = !is_ci
1818
@force_check = false
19+
develop_branch = 'main'
1920

2021
before_all do |lane|
2122
if is_ci
@@ -149,20 +150,12 @@ lane :test_ui do |options|
149150
png_files = git_status(ext: '.png').map { |_, png| png }.flatten
150151
next if png_files.empty?
151152

152-
title = "[CI] Snapshots"
153-
base = current_branch
154-
head = "#{base}-snapshots"
155-
sh("git checkout -b #{head}")
156153
png_files.each { |png| sh("git add #{png}") || true }
157-
sh("git commit -m '#{title}'")
158-
push_to_git_remote(tags: false)
159-
create_pull_request(
160-
api_token: ENV.fetch('GITHUB_TOKEN', nil),
161-
repo: github_repo,
162-
title: title,
163-
head: head,
164-
base: base,
165-
body: 'This PR was created automatically by CI.'
154+
155+
create_pr(
156+
title: '[CI] Snapshots',
157+
base_branch: current_branch,
158+
head_branch: "#{current_branch}-snapshots"
166159
)
167160
end
168161
end
@@ -379,6 +372,33 @@ lane :sources_matrix do
379372
}
380373
end
381374

375+
lane :copyright do
376+
update_copyright(ignore: [derived_data_path, source_packages_path, 'vendor/'])
377+
next unless is_ci
378+
379+
create_pr(
380+
title: '[CI] Update Copyright',
381+
head_branch: "ci/update-copyright-#{Time.now.to_i}"
382+
)
383+
end
384+
385+
private_lane :create_pr do |options|
386+
options[:base_branch] ||= develop_branch
387+
sh("git checkout -b #{options[:head_branch]}")
388+
sh('git add -A')
389+
sh("git commit -m '#{options[:title]}'")
390+
push_to_git_remote(tags: false)
391+
392+
create_pull_request(
393+
api_token: ENV.fetch('GITHUB_TOKEN', nil),
394+
repo: github_repo,
395+
title: options[:title],
396+
head: options[:head_branch],
397+
base: options[:base_branch],
398+
body: 'This PR was created automatically by CI.'
399+
)
400+
end
401+
382402
private_lane :current_branch do
383403
ENV['BRANCH_NAME'] || git_branch
384404
end

fastlane/Pluginfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
gem 'fastlane-plugin-versioning'
66
gem 'fastlane-plugin-emerge'
77
gem 'fastlane-plugin-sonarcloud_metric_kit'
8-
gem 'fastlane-plugin-stream_actions', '0.3.20'
8+
gem 'fastlane-plugin-stream_actions', '0.3.28'
99
gem 'fastlane-plugin-create_xcframework'

0 commit comments

Comments
 (0)