Home

Awesome

tootbot-template

getting started

first things first

next up: code

finally: run

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

on:
  schedule:
    # POSIX cron syntax (every 12th hour), https://crontab.guru/#0_12_*_*_*
    - cron: "0 12 * * *"

name: "Run"

jobs:

  run-bot:
    name: "Run the bot and post to Mastodon"

    runs-on: ubuntu-latest

    # requiired for stefanzweifel/git-auto-commit-action
    permissions:
      contents: write

    env:
      MASTODON_TOKEN: ${{ secrets.MASTODON_TOKEN }}
      MASTODON_INSTANCE: ${{ secrets.MASTODON_INSTANCE }}

    steps:
      - name: "Checkout sources"
        uses: actions/checkout@v4

      - name: "Install PHP"
        uses: shivammathur/setup-php@v2
        with:
          php-version: "8.2"
          coverage: none
          extensions: curl, json, mbstring, openssl, sodium

      - name: "Install dependencies with composer"
        uses: ramsey/composer-install@v3

      - name: "Fetch cacert.pem from curl.haxx.se"
        run: wget -O config/cacert.pem https://curl.se/ca/cacert.pem

      - name: "Run bot"
        run: php ./cli/run.php

      # please note that this requires read/write permissions for the actions runner!
      - name: "Commit log"
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: ":octocat: posted toot"
          file_pattern: "data/posted.json"
          commit_user_name: "github-actions[bot]"
          commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com"
          commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"

related projects

disclaimer

WE'RE TOTALLY NOT RUNNING A PRODUCTION-LIKE ENVIRONMENT ON GITHUB.<br> WE'RE RUNNING A TEST AND POST THE RESULT TO AN EXTERNAL WEBSITE.<br> WE'RE JUST LOOKING IF THE SCRIPT STILL WORKS ON A SCHEDULE N TIMES A DAY.