-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The action for the SEO checker. We still need to acquire an AWS bucket.
- Loading branch information
1 parent
3c28635
commit 51da62e
Showing
1 changed file
with
77 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
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" | ||
|
||
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 broken_link_checker.py |