Create report #537
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: Create report | |
on: | |
schedule: | |
- cron: '0 4 * * *' # Runs daily at 4 AM | |
workflow_dispatch: | |
jobs: | |
create-report: | |
runs-on: ubuntu-latest | |
outputs: | |
status: ${{ steps.set-output.outputs.status }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Python 3.x | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
pip install requests python-whois dnspython beautifulsoup4 selenium pyyaml lxml | |
- name: Reinstall dependencies | |
run: | | |
pip install --upgrade pip | |
pip uninstall whois -y | |
pip install python-whois | |
- name: Set Chrome Version | |
id: chrome_version | |
run: | | |
CHROME_VERSION=$(curl -s "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json" | jq -r '.channels.Stable.version') | |
echo "CHROME_VERSION=$CHROME_VERSION" >> $GITHUB_OUTPUT | |
- name: Setup Chrome and Chromedriver | |
uses: browser-actions/setup-chrome@v1 | |
with: | |
chrome-version: ${{ steps.chrome_version.outputs.CHROME_VERSION }} | |
install-chromedriver: true | |
- name: Verify Chrome and Chromedriver Installation | |
run: | | |
google-chrome --version | |
chromedriver --version | |
CHROME_MAJOR=$(google-chrome --version | cut -d ' ' -f 3 | cut -d '.' -f 1) | |
DRIVER_MAJOR=$(chromedriver --version | cut -d ' ' -f 2 | cut -d '.' -f 1) | |
if [[ "$CHROME_MAJOR" != "$DRIVER_MAJOR" ]]; then | |
echo "Mismatch between Chrome and Chromedriver versions!" | |
exit 1 | |
fi | |
- name: Run Website Tests | |
id: test | |
env: | |
PAGESPEED_API_KEY: ${{ secrets.PAGESPEED_API_KEY }} | |
run: python main.py | |
continue-on-error: true | |
- name: Commit and push report | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add README.md | |
git commit -m "Add generated report" -a || echo "No changes to commit" | |
git push || echo "No changes to push" | |
- name: Fail if error encountered | |
if: steps.set-output.outputs.status == 'error' | |
run: exit 1 |