Skip to content

.github/workflows/sync.yml #13065

.github/workflows/sync.yml

.github/workflows/sync.yml #13065

Workflow file for this run

on:
#push
schedule:
# Trigger the sync every 10 minutes.
- cron: '*/10 * * * *'
# Allow triggering the sync manually.
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
environment: Cron
steps:
- name: Check out the repo itself
uses: actions/checkout@v3
- name: Restore sync cache folder
uses: actions/cache@v3
with:
path: cache
# We don't really need a cache key as we never want to throw the cache
# away. We need a unique number per run so that the cache always gets
# saved. Then the next run will fall back to the restore-key and
# retrieve the newest cache entry. At the end of the workflow we
# clean up older cache entries over the Github API to free up space.
# This is a hacky way to use the Github cache as persistent file
# system :-)
key: cache-${{ github.run_number }}
restore-keys: cache-
- name: Check if cache files are there
run: mkdir -p cache && ls -la cache
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip' # caching pip dependencies
- name: Install requirements
run: pip install -r requirements.txt
- name: Run mastweet.py
run: cd cache && python ../mastweet.py
env:
MASTODON_CLIENT_ID: ${{ secrets.MASTODON_CLIENT_ID }}
MASTODON_CLIENT_SECRET: ${{ secrets.MASTODON_CLIENT_SECRET }}
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_INSTANCE_URL: ${{ vars.MASTODON_INSTANCE_URL }}
MASTODON_HASHTAG: ${{ vars.MASTODON_HASHTAG }}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
- name: Delete old Github Actions cache entries
run: chmod +x cache-cleanup.sh && ./cache-cleanup.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}