-
Notifications
You must be signed in to change notification settings - Fork 46
65 lines (57 loc) · 2.06 KB
/
broken-link-checker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: broken-link-checker
on:
schedule:
- cron: "0 18 * * 5"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository content
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install "bs4"
python -m pip install "requests"
python -m pip install "pandas"
python -m pip install "datetime"
python -m pip install "openpyxl"
python -m pip install "ultimate-sitemap-parser"
python -m pip install "pyjwt[crypto]"
- name: Generate GitHub App JWT
id: generate_jwt
env:
APP_ID: ${{ secrets.SECRET_APP_ID }}
PRIVATE_KEY: ${{ secrets.SECRET_APP_KEY }}
run: |
echo "Generating JWT..."
JWT=$(python -c "
import jwt, time, os;
payload = {
'iat': int(time.time()),
'exp': int(time.time()) + (10 * 60),
'iss': os.getenv('APP_ID')
};
private_key = os.getenv('PRIVATE_KEY').replace('\\n', '\n');
encoded_jwt = jwt.encode(payload, private_key, algorithm='RS256');
print(encoded_jwt);
")
echo "JWT=$JWT" >> $GITHUB_ENV
- name: Request GitHub App Installation Token
id: request_token
env:
JWT: ${{ env.JWT }}
INSTALLATION_ID: ${{ secrets.SECRET_INSTALLATION_ID }}
run: |
echo "Requesting installation token..."
INSTALLATION_TOKEN=$(curl -X POST -H "Authorization: Bearer $JWT" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations/$INSTALLATION_ID/access_tokens | jq -r '.token')
echo "INSTALLATION_TOKEN=$INSTALLATION_TOKEN" >> $GITHUB_ENV
- name: Execute broken link script
env:
GIT_TOKEN: ${{ env.INSTALLATION_TOKEN }}
run: |
python broken_link_checker.py