ApplSec bot #23922
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
name: ApplSec bot | |
on: | |
schedule: | |
# every full hour | |
- cron: "0 * * * *" | |
# between 4 and 8 pm UTC on weekdays run every 15 minutes as that is the time when updates usually get released | |
- cron: "*/15 16-20 * * 1-5" | |
workflow_dispatch: | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main | |
uses: actions/checkout@v4 | |
with: | |
path: main | |
- name: Checkout posted_data_json | |
uses: actions/checkout@v4 | |
with: | |
ref: posted_data_json | |
path: branch | |
- name: Set up posted_data.json | |
run: | | |
cp branch/posted_data.json main/src/ | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
cache: "pip" | |
- name: Install dependencies | |
run: | | |
pip install -r main/requirements.txt | |
- name: Set Timezone to CET/CEST | |
run: | | |
sudo timedatectl set-timezone "Europe/Berlin" | |
- name: Run ApplSec bot | |
env: | |
TWITTER_API_KEY: ${{ secrets.TWITTER_API_KEY }} | |
TWITTER_API_KEY_SECRET: ${{ secrets.TWITTER_API_KEY_SECRET }} | |
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} | |
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} | |
TWITTER_API_KEY_TEST: ${{ secrets.TWITTER_API_KEY_TEST }} | |
TWITTER_API_KEY_SECRET_TEST: ${{ secrets.TWITTER_API_KEY_SECRET_TEST }} | |
TWITTER_ACCESS_TOKEN_TEST: ${{ secrets.TWITTER_ACCESS_TOKEN_TEST }} | |
TWITTER_ACCESS_TOKEN_SECRET_TEST: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET_TEST }} | |
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }} | |
MASTODON_ACCESS_TOKEN_TEST: ${{ secrets.MASTODON_ACCESS_TOKEN_TEST }} | |
run: python main/src/main.py | |
- name: Save posted_data.json | |
if: always() | |
run: | | |
cd branch/ | |
cp ../main/src/posted_data.json . | |
if [[ $(git status --porcelain) ]]; then | |
# Changes | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add . | |
git diff --staged --quiet || git commit -m "$(date +'%Y-%m-%d %I:%M:%S %p')" && git push | |
else | |
# No changes | |
: | |
fi |