Skip to content

Update Stats

Update Stats #16807

Workflow file for this run

name: Update Stats
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: "0 1 * * *" # Update once a day, now, that the project is not active
push:
branches: [master]
paths:
- '.github/workflows/update_stats.yaml'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
path: master
ref: master
- name: Checkout repository
uses: actions/checkout@v2
with:
path: gh-pages
ref: gh-pages
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
# role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
# role-external-id: ${{ secrets.AWS_ROLE_EXTERNAL_ID }}
# role-duration-seconds: 1200
# role-session-name: MySessionName
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Fetch logs
working-directory: master
run: "pip install -r requirements.txt && aws logs tail /aws/lambda/FuelFinder --since 3h | grep '{\"id\"' | cut -f 3- -d ' ' | python data/create_json.py update-stats fuelfinder/public/stations.json"
- name: Push stations.json to gh-pages and master
working-directory: gh-pages
run: |
git config --global user.name $user_name
git config --global user.email $user_email
git remote set-url origin https://${github_token}@github.com/${repository}
cp ../master/fuelfinder/public/stations.json .
git add stations.json
git commit -m "Automated update"
git push origin HEAD
cd ../master/
git add fuelfinder/public/stations.json
git commit -m "Automated update"
git push origin HEAD
env:
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
github_token: ${{ secrets.ACTIONS_DEPLOY_ACCESS_TOKEN }}
repository: ${{ github.repository }}