-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Post a feed of manual PRs to the
#pkg-registration-manual-prs
chann…
…el on Slack
- Loading branch information
1 parent
4056bbd
commit eaf2c5b
Showing
7 changed files
with
91 additions
and
5 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
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,74 @@ | ||
name: Manual PRs feed | ||
on: | ||
pull_request: # TODO: delete this line | ||
# pull_request_target: # TODO: uncomment this line | ||
types: [ opened, reopened ] # TODO: delete this line | ||
# types: [ opened ] # TODO: uncomment this line | ||
permissions: | ||
contents: read | ||
jobs: | ||
manual-prs-slack: | ||
if: (github.event.pull_request.user.login != 'JuliaRegistrator') && (github.event.pull_request.user.login != 'jlbuild') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: julia-actions/setup-julia@latest | ||
with: | ||
version: 1.6.2 | ||
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 | ||
- name: Send to Slack | ||
shell: julia --color=yes {0} | ||
run: | | ||
endpoint = ENV["SLACK_ENDPOINT"] | ||
if isempty(endpoint) | ||
@info "Endpoint not specified; missing secret? Exiting." | ||
exit(0) | ||
end | ||
pr_number_str = ENV["PR_NUMBER"] | ||
pr_number_int = parse(Int, ENV["PR_NUMBER"]) # make sure that it is indeed an integer | ||
pr_url = "https://github.com/JuliaRegistries/General/pull/$(pr_number_int)" | ||
const allowed_chars = vcat( | ||
'A':'Z', | ||
'a':'z', | ||
'0':'9', | ||
[' ', '-'], | ||
) | ||
const f = char -> char in allowed_chars ? char : '-' | ||
const sanitize = str -> map(f, str) | ||
const truncate = str -> first(str, 280) | ||
pr_author = ENV["PR_AUTHOR"] |> sanitize |> truncate | ||
pr_title = ENV["PR_TITLE"] |> sanitize |> truncate | ||
text_lines = String[ | ||
"- Title: $(pr_title)", | ||
"- Author: $(pr_author)", | ||
"- URL: $(pr_url)", | ||
] | ||
text = join(text_lines, '\n') | ||
using Pkg | ||
Pkg.activate(mktempdir()) | ||
Pkg.add(name="Slack", version="0.1") | ||
using Slack | ||
attachment = Dict( | ||
"color" => "#36a64f", | ||
"fallback" => pr_title, | ||
"title" => pr_title, | ||
"title_link" => pr_url, | ||
"text" => text, | ||
) | ||
data = Dict("attachments" => [attachment]) | ||
if !startswith(endpoint, "/") | ||
endpoint = string("/", endpoint) | ||
end | ||
@info "Told Slack: $(data)" | ||
response = sendattachmenttoslack(data, endpoint) | ||
@info "Slack said: $response" | ||
env: | ||
SLACK_ENDPOINT: ${{ secrets.JULIALANGSLACKENDPOINT_MANUAL_PRS }} | ||
PR_NUMBER: ${{ github.event.number }} | ||
PR_TITLE: ${{ github.event.pull_request.title }} | ||
PR_AUTHOR: ${{ github.event.pull_request.user.login }} |
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