Skip to content

Daily Screenshot

Daily Screenshot #12

Workflow file for this run

name: Daily Screenshot
on:
schedule:
# Run the job every day at noon (12:00 PM UTC)
- cron: '0 12 * * *'
jobs:
take-screenshot:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install selenium pillow
- name: Download ChromeDriver
run: |
sudo apt-get update
sudo apt-get install -y unzip
wget -O /tmp/chromedriver.zip https://chromedriver.storage.googleapis.com/110.0.5481.77/chromedriver_linux64.zip
unzip /tmp/chromedriver.zip -d /usr/local/bin/
- name: Install Chrome browser
run: |
sudo apt-get install -y chromium-browser
- name: Run screenshot script
run: python capture_screenshot.py
- name: Install gdrive
run: |
wget -O /tmp/gdrive https://github.com/prasmussen/gdrive/releases/download/2.1.0/gdrive-linux-x64
chmod +x /tmp/gdrive
sudo mv /tmp/gdrive /usr/local/bin/gdrive
- name: Configure gdrive with service account
env:
GDRIVE_SERVICE_ACCOUNT_KEY: ${{ secrets.GDRIVE_SERVICE_ACCOUNT_KEY }}
run: |
echo "${GDRIVE_SERVICE_ACCOUNT_KEY}" > /tmp/service-account.json
gdrive about --service-account /tmp/service-account.json
- name: Upload screenshot to Google Drive
env:
GDRIVE_SERVICE_ACCOUNT_KEY: ${{ secrets.GDRIVE_SERVICE_ACCOUNT_KEY }}
run: |
echo "${GDRIVE_SERVICE_ACCOUNT_KEY}" > /tmp/service-account.json
gdrive upload --service-account /tmp/service-account.json --parent <your-google-drive-folder-id> screenshot.png
- name: Upload cropped screenshot to Google Drive
env:
GDRIVE_SERVICE_ACCOUNT_KEY: ${{ secrets.GDRIVE_SERVICE_ACCOUNT_KEY }}
run: |
echo "${GDRIVE_SERVICE_ACCOUNT_KEY}" > /tmp/service-account.json
gdrive upload --service-account /tmp/service-account.json --parent <your-google-drive-folder-id> cropped_screenshot.png