-
Notifications
You must be signed in to change notification settings - Fork 46
78 lines (69 loc) · 2.73 KB
/
seo_check.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
66
67
68
69
70
71
72
73
74
75
76
77
78
name: SEO Report and GitHub Issue
# Triggers the workflow every Friday at 18:00 UTC (which is 20:00 CET)
on:
schedule:
- cron: "0 18 * * 5"
workflow_dispatch:
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 "boto3"
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: Set environment variables
run: |
echo "FULL_DOMAIN=https://tilburgsciencehub.com" >> $GITHUB_ENV
echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> $GITHUB_ENV
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> $GITHUB_ENV
echo "AWS_REGION=${{ secrets.AWS_REGION }}" >> $GITHUB_ENV
echo "AWS_BUCKET=${{ secrets.AWS_BUCKET }}" >> $GITHUB_ENV
echo "GIT_USERNAME=tilburgsciencehub" >> $GITHUB_ENV
echo "GIT_REPOSITORY=website" >> $GITHUB_ENV
- name: Execute SEO report script
env:
GIT_TOKEN: ${{ env.INSTALLATION_TOKEN }}
run: |
python seo.py