Skip to content

Commit 193e239

Browse files
committed
First commit
0 parents  commit 193e239

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

.github/slackchecker.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import os
2+
import requests
3+
4+
r = requests.head("https://wagtail.org/slack", headers={"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"}, allow_redirects=True)
5+
if r.url.startswith('https://wagtailcms.slack.com/join/shared_invite/'):
6+
print("Slack invitation link is OK")
7+
else:
8+
print("Slack invitation link has expired")
9+
10+
if "SLACK_WEBHOOK_URL" in os.environ:
11+
print("Reporting to #nightly-build-failures slack channel")
12+
response = requests.post(
13+
os.environ["SLACK_WEBHOOK_URL"],
14+
json={
15+
"text": "Slack invitation link has expired. Please generate a new one and set it as the /slack redirect on wagtail.org",
16+
},
17+
)
18+
19+
print(f"Slack responded with: {response}")
20+
21+
else:
22+
print(
23+
"Unable to report to #nightly-build-failures slack channel because SLACK_WEBHOOK_URL is not set"
24+
)

.github/workflows/slackchecker.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Slack checker
2+
3+
on:
4+
schedule:
5+
- cron: "10 * * * *"
6+
7+
workflow_dispatch:
8+
9+
jobs:
10+
nightly-test:
11+
# Cannot check the existence of secrets, so limiting to repository name to prevent all forks to run nightly.
12+
# See: https://github.com/actions/runner/issues/520
13+
if: ${{ github.repository == 'wagtail/slackchecker' }}
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python 3.9
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: 3.9
22+
- name: Install dependencies
23+
run: |
24+
pip install requests
25+
- name: Test
26+
id: test
27+
continue-on-error: true
28+
run: |
29+
python .github/slackchecker.py
30+
env:
31+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# slackchecker
2+
3+
a script to notify us when the Slack invitation link on wagtail.org has expired

0 commit comments

Comments
 (0)