Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Clerk work

Clerk work #16412

Workflow file for this run

###############################################################################
# Copyright (C) 2022 Siddh Raman Pant
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# The online repository may be found at <github.com/covid-saarani/lipik>.
###############################################################################
# Note: Indentation here is of 2 spaces.
name: Clerk work
on:
schedule: # Every hour (at the UTC 45th minute => IST 15th minute).
- cron: 45 * * * *
workflow_dispatch: {} # For manual switch.
push: # Whenever we update code in the main branch, or this action file.
branches:
- main
paths:
- "**.py"
- ".github/workflows/action.yml"
# End of on.
jobs:
scheduled:
runs-on: ubuntu-latest
steps:
- name: Checkout Lipik
uses: actions/checkout@v3
with:
ref: main
path: lipik
- name: Checkout Saarani
uses: actions/checkout@v3
with:
ref: main
repository: covid-saarani/saarani
ssh-key: ${{ secrets.SAARANI_DEPLOY }}
path: saarani
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.9.x"
cache: "pip" # This caches pip wheels, not package installation.
- name: Generate locale and change timezone
run: |
sudo locale-gen en_IN
sudo locale-gen en_IN.UTF-8
sudo timedatectl set-timezone Asia/Kolkata
# Thanks to https://stackoverflow.com/a/62639424 for suggesting to cache
# venv instead of pip wheels. This is much faster and does not require
# installation of packages again. Note that environment isn't preserved
# between runs.
- name: Setup venv cache
uses: actions/cache@v3
with:
path: ~/venv
key: ${{ runner.os }}-venv-${{ secrets.SOME_STRING }}-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-venv-${{ secrets.SOME_STRING }}-
# Due to existing installation, pip install will be fast.
- name: Install dependencies
working-directory: ./lipik
run: |
python3 -m venv ~/venv
. ~/venv/bin/activate
pip install -r requirements.txt
# Our main clerk work is here.
- name: Make data and store in the Saarani folder
working-directory: ./lipik
run: |
. ~/venv/bin/activate
python3 lipik.py
- name: Commit changes (if any)
working-directory: ./saarani
run: |
if [[ $(git status -s) ]]; then
git config user.name github-actions
git config user.email github-actions[bot]@users.noreply.github.com
git add .
git commit -m "Auto fetch: $(date +'%Y-%m-%d %R')"
git push
fi
# End of steps.
# End of scheduled.
# End of jobs.
# End of file.