From d6e6f659755ca8cf80246d11a3f153e4fb899a22 Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Mon, 8 Jan 2024 15:16:31 +0000 Subject: [PATCH] Implement copyright action --- .github/workflows/update-copyright.yml | 33 ++++++++++++++++++++++++++ Gemfile.lock | 4 ++-- fastlane/Fastfile | 21 ++++++++++++++++ fastlane/Pluginfile | 2 +- 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/update-copyright.yml diff --git a/.github/workflows/update-copyright.yml b/.github/workflows/update-copyright.yml new file mode 100644 index 00000000000..c8ae94b390e --- /dev/null +++ b/.github/workflows/update-copyright.yml @@ -0,0 +1,33 @@ +name: Copyright + +on: + schedule: + # Runs "At 08:00 on day-of-month 1 in January" + - cron: '0 8 1 1 *' + + workflow_dispatch: + +env: + HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI + +jobs: + copyright: + name: Copyright + runs-on: macos-13 + steps: + - uses: actions/checkout@v3.1.0 + - uses: ./.github/actions/ruby-cache + - run: bundle exec fastlane copyright + timeout-minutes: 5 + env: + GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} + - uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + text: "You shall not pass!" + job_name: "${{ github.workflow }}: ${{ github.job }}" + fields: message,commit,author,action,workflow,job,took + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + MATRIX_CONTEXT: ${{ toJson(matrix) }} + if: failure() diff --git a/Gemfile.lock b/Gemfile.lock index 353e807915d..885ae55178a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -200,7 +200,7 @@ GEM fastlane pry fastlane-plugin-sonarcloud_metric_kit (0.2.1) - fastlane-plugin-stream_actions (0.3.25) + fastlane-plugin-stream_actions (0.3.26) xctest_list (= 1.2.1) fastlane-plugin-versioning (0.5.2) ffi (1.16.3) @@ -427,7 +427,7 @@ DEPENDENCIES fastlane-plugin-emerge fastlane-plugin-lizard fastlane-plugin-sonarcloud_metric_kit - fastlane-plugin-stream_actions (= 0.3.25) + fastlane-plugin-stream_actions (= 0.3.26) fastlane-plugin-versioning jazzy json diff --git a/fastlane/Fastfile b/fastlane/Fastfile index eab1e4045d7..d1f05c280da 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -640,6 +640,27 @@ lane :sources_matrix do } end +lane :copyright do + update_copyright(ignore: [derived_data_path, source_packages_path]) + next unless is_ci + + branch_name = "ci/update-copyright-#{Time.now.to_i}" + commit_message = '[CI] Update Copyright' + sh("git checkout -b #{branch_name}") + sh('git add -A') + sh("git commit -m '#{commit_message}'") + push_to_git_remote(tags: false) + + create_pull_request( + api_token: ENV.fetch('GITHUB_TOKEN', nil), + repo: github_repo, + title: commit_message, + head: branch_name, + base: 'develop', + body: 'This PR was created automatically by CI.' + ) +end + private_lane :current_branch do ENV['BRANCH_NAME'] || git_branch end diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile index fa387ce5f20..fa982feb1a2 100644 --- a/fastlane/Pluginfile +++ b/fastlane/Pluginfile @@ -6,4 +6,4 @@ gem 'fastlane-plugin-versioning' gem 'fastlane-plugin-emerge' gem 'fastlane-plugin-create_xcframework' gem 'fastlane-plugin-sonarcloud_metric_kit' -gem 'fastlane-plugin-stream_actions', '0.3.25' +gem 'fastlane-plugin-stream_actions', '0.3.26'