.github/workflows/cron.yml #1152
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
# References: | |
# https://github.com/actions/checkout/issues/13 | |
# https://github.community/t/github-actions-bot-email-address/17204/5 | |
on: | |
schedule: | |
- cron: '30 06 * * *' | |
jobs: | |
setup-python-and-update-data: | |
name: Setup Python And Update Data | |
runs-on: ubuntu-latest | |
# timeout-minutes: 60 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Set Up Python Version | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Create env File | |
run: | | |
cd data/ | |
cat << EOF > .env | |
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_S3_BUCKET=${{ secrets.AWS_S3_BUCKET }} | |
AWS_S3_FILE_NAME=${{ secrets.AWS_S3_FILE_NAME }} | |
TITLE_KEYWORD=${{ secrets.TITLE_KEYWORD }} | |
EOF | |
- name: Install Dependencies | |
run: | | |
python3 -m pip install --user pipx | |
python3 -m pipx ensurepath | |
pipx install poetry | |
cat << EOF > poetry.toml | |
[virtualenvs] | |
in-project = true | |
EOF | |
poetry install | |
- name: Update Data Folder | |
run: | | |
source $PWD/.venv/bin/activate | |
cd data/ && python main.py | |
cd .. | |
- name: Check For Modified Files | |
id: git-check | |
run: echo ::set-output name=modified::$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi) | |
- name: Git Commit | |
if: steps.git-check.outputs.modified == 'true' | |
run: | | |
echo $PWD | |
git config user.name 'github-actions[bot]' | |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
git add . | |
git commit -m "[Cron commit] - upate data on $(date -u '+D:%Y-%m-%d, T:%H:%M:%S / UTC+0')" | |
- name: Push Changes | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main |