-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3143 from lucasmlp/release-v2.7
Automation improvements to release-v2.7 branch
- Loading branch information
Showing
6 changed files
with
175 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Validation Check | ||
|
||
on: | ||
pull_request_review: | ||
types: [submitted] | ||
|
||
jobs: | ||
check-reaction: | ||
name: Check for positive reaction on bot's latest validation comment | ||
if: startsWith(github.event.pull_request.base.ref, 'dev-v') || startsWith(github.event.pull_request.base.ref, 'release-v') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check for positive reaction on bot's latest validation comment | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
// Get comments on the PR | ||
const comments = await github.issues.listComments({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
// Sort comments based on their creation datetime in descending order | ||
const sortedComments = comments.data.sort((a, b) => new Date(b.created_at) - new Date(a.created_at)); | ||
// Find the latest validation comment by github-actions[bot] | ||
const latestValidationComment = sortedComments.find(comment => comment.user.login === 'github-actions[bot]' && comment.body.startsWith("## Validation steps")); | ||
if (latestValidationComment) { | ||
const reactions = await github.reactions.listForIssueComment({ | ||
comment_id: latestValidationComment.id, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
// Check if there's a thumbs-up reaction on the bot's validation comment | ||
const thumbsUpReaction = reactions.data.some(reaction => reaction.content === '+1'); | ||
if (thumbsUpReaction) { | ||
console.log("The validation comment by github-actions[bot] has the required thumbs-up reaction."); | ||
} else { | ||
const createdAt = new Date(latestValidationComment.created_at).toLocaleString('en-US', { timeZoneName: 'short' }); | ||
console.error("Failed Check - Comment Created At:", createdAt); | ||
core.setFailed("The latest validation comment by github-actions[bot] does not have the required thumbs-up reaction!"); | ||
} | ||
} else { | ||
core.setFailed("No validation comments by github-actions[bot] found."); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Validation Comment | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
- dev-v* | ||
- release-v* | ||
|
||
jobs: | ||
validation-comment: | ||
name: Make validation comment on PR | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
steps: | ||
- name: Make validation comment | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
github.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: | ||
`## Validation steps | ||
- Ensure all container images have repository and tag on the same level to ensure that all container images are included in rancher-images.txt which are used by airgap customers. | ||
<pre> | ||
Ex:- | ||
longhorn-controller: | ||
repository: rancher/hardened-sriov-cni | ||
tag: v2.6.3-build20230913 | ||
</pre> | ||
- Add a 👍 (thumbs up) reaction to this comment once done. CI won't pass without this reaction to the github-action bot's latest validation comment. | ||
- Approve the PR to run the CI check.` | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
#! /usr/bin/env ruby | ||
| ||
|
||
require "json" | ||
require "pathname" | ||
require "yaml" | ||
| ||
|
||
pwd = Pathname(Dir.pwd) | ||
| ||
|
||
regsync = YAML.load((pwd + "regsync.yaml").read) | ||
| ||
|
||
regsync["sync"].sum do |sync| | ||
sync["tags"]["allow"].count | ||
end.then do |sum| | ||
puts "total tags to consider: #{sum}" | ||
end | ||
| ||
|
||
regsync["sync"].each do |sync| | ||
regsync.merge("sync" => [sync]).then do |regsync| | ||
(pwd + "regsync" + sync["source"]).then do |dir| | ||
(pwd + "split-regsync" + sync["source"]).then do |dir| | ||
dir.mkpath | ||
(dir + "regsync.yaml").write(YAML.dump(regsync)) | ||
(dir + "split-regsync.yaml").write(YAML.dump(regsync)) | ||
end | ||
end | ||
end |
This file contains 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