-
-
Notifications
You must be signed in to change notification settings - Fork 7
76 lines (63 loc) · 2.25 KB
/
create-report.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
name: Create report
on:
schedule:
- cron: '0 4 * * *'
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
- name: Install Chrome
run: |
sudo apt-get update
sudo apt-get install -y google-chrome-stable
- name: Install Chromedriver
run: |
# Get the installed Chrome version
CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+')
# Find the latest compatible Chromedriver version
DRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION%.*}")
# Download and install Chromedriver
curl -O "https://chromedriver.storage.googleapis.com/${DRIVER_VERSION}/chromedriver_linux64.zip"
unzip chromedriver_linux64.zip -d ~/ && rm chromedriver_linux64.zip
sudo mv -f ~/chromedriver /usr/local/bin/chromedriver
sudo chown root:root /usr/local/bin/chromedriver
sudo chmod 0755 /usr/local/bin/chromedriver
- name: Verify Chrome Installation
run: |
google-chrome --version
chromedriver --version
- name: Run Website Tests
id: test
run: python main.py
continue-on-error: false # Ensures the workflow stops on error
- name: Set Output status
id: set-output
run: |
if [[ -f error.log ]]; then
echo "Error encountered in Website Tests"
echo "::set-output name=status::error"
else
echo "::set-output name=status::success"
fi
- 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
- name: Fail if error encountered
if: steps.set-output.outputs.status == 'error'
run: exit 1