Update broken-link-checker.yml #4
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
name: broken-link-checker | |
on: | |
push: | |
branches: | |
- main-flask | |
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 "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 |