Skip to content

Commit 05f9b2d

Browse files
authored
Update NOTICES workflow. (#9754)
* Run workflow in nightly.
1 parent e376c29 commit 05f9b2d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

.github/workflows/notice_generation.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ on:
55
paths:
66
- '.github/workflows/notice_generation.yml'
77
- '.github/actions/notices_generation**'
8+
schedule:
9+
# Run every day at 5am (PST) - cron uses UTC times
10+
- cron: '0 13 * * *'
811
jobs:
912
generate_a_notice:
1013
# Don't run on private repo.
11-
if: github.repository == 'Firebase/firebase-ios-sdk' && github.event_name != 'schedule'
14+
if: github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule'
1215
runs-on: macos-12
1316
name: Generate NOTICES
1417
env:
@@ -38,12 +41,13 @@ jobs:
3841
notices-path: ${{ env.NOTICES_PATH }}
3942
- name: Create a pull request
4043
run: |
44+
RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
4145
gem install octokit
4246
ruby scripts/create_pull_request.rb \
4347
--repo-root ${GITHUB_WORKSPACE} \
4448
--repo-token ${{ secrets.GITHUB_TOKEN }} \
4549
--target-path ${{ env.NOTICES_PATH }} \
4650
--pr-title "NOTICES Change" \
47-
--pr-body "NOTICES Change is detected." \
51+
--pr-body "NOTICES Change is detected in [this GitHub Actions Run](${RUN_URL})." \
4852
--commit-comment "NOTICES change."
4953
shell: bash

scripts/create_pull_request.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
opts.on('-n', '--target-path PATH', 'Path of targeted file or dir') { |v| @options[:target_path] = v }
3333
opts.on('--pr-title PR_TITLE', 'Title of a PR') { |v| @options[:pr_title] = v }
3434
opts.on('--pr-body PR_BODY', 'Body of a PR') { |v| @options[:pr_body] = v }
35-
opts.on('--base-branch', 'A new branch will be generated if not specified or the branch does not exist.') { |v| @options[:base_branch] = v }
36-
opts.on('--commit-comment', 'Commit comment') { |v| @options[:commit_comment] = v }
35+
opts.on('--base-branch BASE_BRANCH', 'A new branch will be generated if not specified or the branch does not exist.') { |v| @options[:base_branch] = v }
36+
opts.on('--commit-comment COMMIT_COMMENT', 'Commit comment') { |v| @options[:commit_comment] = v }
3737
end.parse!
3838

3939
raise OptionParser::MissingArgument if @options[:repo_token].nil? || @options[:target_path].nil?
@@ -47,17 +47,16 @@
4747
ACCESS_TOKEN=@options[:repo_token]
4848
TARGET_PATH=@options[:target_path]
4949
PR_TITLE=@options[:pr_title]
50-
PR_BODY=@options[:pr_boday]
50+
PR_BODY=@options[:pr_body]
5151
BASE_BRANCH=@options[:base_branch]
5252
COMMIT_COMMENT=@options[:commit_comment]
5353

5454
def generate_pr_for_target_changes(repo_root:, target_path:)
55-
system("cd #{REPO_ROOT}\ngit checkout -b #{BASE_BRANCH}\n")
5655
if `git diff #{TARGET_PATH}`==""
5756
puts "The file, #{TARGET_PATH}, has no changes."
5857
return
5958
end
60-
system("git add #{TARGET_PATH}\ngit commit -m \"#{COMMIT_COMMENT}\"\n git push -u origin #{BASE_BRANCH}")
59+
system("cd #{REPO_ROOT}\ngit checkout -b #{BASE_BRANCH}\ngit add #{TARGET_PATH}\ngit commit -m \"#{COMMIT_COMMENT}\"\ngit push -u origin #{BASE_BRANCH}")
6160
client = Octokit::Client.new(access_token: ACCESS_TOKEN)
6261
client.create_pull_request("firebase/firebase-ios-sdk", "master", BASE_BRANCH, PR_TITLE, PR_BODY)
6362
end
@@ -68,4 +67,3 @@ def main()
6867
end
6968

7069
main()
71-

0 commit comments

Comments
 (0)