mirror of
https://github.com/apache/superset.git
synced 2026-04-24 18:44:53 +00:00
build: inline external Github Actions to unblock CI (#12241)
* build: inline cached-dependencies to unblock CI * Run E2E on pull_request on;y * Inline all external actions * Checkout needed for internal actions Also fixes pre-commit * Add missing files
This commit is contained in:
13
.github/actions/comment-on-pr/Dockerfile
vendored
Normal file
13
.github/actions/comment-on-pr/Dockerfile
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM ruby:2.6.0
|
||||
|
||||
LABEL "com.github.actions.name"="Comment on PR"
|
||||
LABEL "com.github.actions.description"="Leaves a comment on an open PR matching a push event."
|
||||
LABEL "com.github.actions.repository"="https://github.com/unsplash/comment-on-pr"
|
||||
LABEL "com.github.actions.maintainer"="Aaron Klaassen <aaron@unsplash.com>"
|
||||
LABEL "com.github.actions.icon"="message-square"
|
||||
LABEL "com.github.actions.color"="blue"
|
||||
|
||||
RUN gem install octokit
|
||||
|
||||
ADD entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
7
.github/actions/comment-on-pr/LICENSE
vendored
Normal file
7
.github/actions/comment-on-pr/LICENSE
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright 2019 Unsplash Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
27
.github/actions/comment-on-pr/README.md
vendored
Normal file
27
.github/actions/comment-on-pr/README.md
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# Comment on PR via GitHub Action
|
||||
|
||||
A GitHub action to comment on the relevant open PR when a commit is pushed.
|
||||
|
||||
## Usage
|
||||
|
||||
- Requires the `GITHUB_TOKEN` secret.
|
||||
- Requires the comment's message in the `msg` parameter.
|
||||
- Supports `push` and `pull_request` event types.
|
||||
|
||||
### Sample workflow
|
||||
|
||||
```
|
||||
name: comment-on-pr example
|
||||
on: pull_request
|
||||
jobs:
|
||||
example:
|
||||
name: sample comment
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: comment PR
|
||||
uses: unsplash/comment-on-pr@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
msg: "Check out this message!"
|
||||
```
|
||||
15
.github/actions/comment-on-pr/action.yml
vendored
Normal file
15
.github/actions/comment-on-pr/action.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
name: Comment on PR
|
||||
author: Aaron Klaassen <aaron@unsplash.com>
|
||||
description: Leaves a comment on an open PR matching a push event.
|
||||
branding:
|
||||
icon: 'message-square'
|
||||
color: 'blue'
|
||||
inputs:
|
||||
msg:
|
||||
description: Comment's message
|
||||
required: true
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.msg }}
|
||||
47
.github/actions/comment-on-pr/entrypoint.sh
vendored
Executable file
47
.github/actions/comment-on-pr/entrypoint.sh
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require "json"
|
||||
require "octokit"
|
||||
|
||||
json = File.read(ENV.fetch("GITHUB_EVENT_PATH"))
|
||||
event = JSON.parse(json)
|
||||
|
||||
github = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"])
|
||||
|
||||
if !ENV["GITHUB_TOKEN"]
|
||||
puts "Missing GITHUB_TOKEN"
|
||||
exit(1)
|
||||
end
|
||||
|
||||
if ARGV.empty?
|
||||
puts "Missing message argument."
|
||||
exit(1)
|
||||
end
|
||||
|
||||
repo = event["repository"]["full_name"]
|
||||
|
||||
if ENV.fetch("GITHUB_EVENT_NAME") == "pull_request"
|
||||
pr_number = event["number"]
|
||||
else
|
||||
pulls = github.pull_requests(repo, state: "open")
|
||||
|
||||
push_head = event["after"]
|
||||
pr = pulls.find { |pr| pr["head"]["sha"] == push_head }
|
||||
|
||||
if !pr
|
||||
puts "Couldn't find an open pull request for branch with head at #{push_head}."
|
||||
exit(1)
|
||||
end
|
||||
pr_number = pr["number"]
|
||||
end
|
||||
message = ARGV.join(' ')
|
||||
|
||||
coms = github.issue_comments(repo, pr_number)
|
||||
duplicate = coms.find { |c| c["user"]["login"] == "github-actions[bot]" && c["body"] == message }
|
||||
|
||||
if duplicate
|
||||
puts "The PR already contains a database change notification"
|
||||
exit(0)
|
||||
end
|
||||
|
||||
github.add_comment(repo, pr_number, message)
|
||||
Reference in New Issue
Block a user