Skip to content

Commit

Permalink
Post a feed of manual PRs to the #pkg-registration-manual-prs chann…
Browse files Browse the repository at this point in the history
…el on Slack
  • Loading branch information
DilumAluthge committed Aug 21, 2022
1 parent 4056bbd commit eaf2c5b
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/announce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ on:
pull_request:
types:
- closed
permissions:
contents: read
jobs:
announce-twitter:
# https://stackoverflow.com/a/59588725/12486544
if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'new package') }}
if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'new package') }}
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@ce353a9bc8bd2a581d0533eb1d0ffc6f60563eb0 # v1.7.1
Expand All @@ -26,13 +28,13 @@ jobs:
Pkg.add(name="Twitter", version="0.9")
using Twitter
twitterauth(ENV["API_Key"], ENV["API_Key_Secret"], ENV["Access_Token"], ENV["Access_Token_Secret"])
myStatus = string(ENV["PR_NAME"], " announced #JuliaLang\n\n$text")
@info "Tweet to be sent: $myStatus"
@info "Tweet length: $(length(myStatus))"
response = post_status_update(status=myStatus)
@info "Twitter said: $response"
env:
SLACK_ENDPOINT: ${{ secrets.JULIALANGSLACKENDPOINT }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/breaking_change_feed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Send breaking to Zulip
on:
pull_request:
types: [ labeled ]
permissions:
contents: read
jobs:
update-zulip-breaking:
if: ${{ (github.event.label.name == 'BREAKING' || github.event.label.name == 'zulip test') && github.repository == github.event.pull_request.head.repo.full_name }}
Expand Down Expand Up @@ -38,4 +40,3 @@ jobs:
type: 'stream'
topic: 'Package breaking updates'
content: ${{ steps.zulip.outputs.content }}

2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
workflow_dispatch:
env:
JULIA_PKG_USE_CLI_GIT: true
permissions:
contents: read
jobs:
CI:
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/feed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Send to feeds
on:
pull_request:
types: [ labeled ]
permissions:
contents: read
jobs:
update-slack:
if: ${{ github.event.label.name == 'new package' && github.repository == github.event.pull_request.head.repo.full_name }}
Expand All @@ -20,7 +22,7 @@ jobs:
@info "Endpoint not specified; missing secret? Exiting."
exit(0)
end
include(joinpath(ENV["GITHUB_WORKSPACE"], ".ci", "parse_env.jl"))
text, pr_url = parse_env(ENV)
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/feed_manual_prs.yml
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 }}
2 changes: 2 additions & 0 deletions .github/workflows/update_manifests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
schedule:
- cron: 0 0 * * 1
workflow_dispatch:
permissions:
contents: read
defaults:
run:
shell: bash
Expand Down

0 comments on commit eaf2c5b

Please sign in to comment.