DEV Community

Martin Ratinaud
Martin Ratinaud

Posted on • Edited on

3 1

Github optimal cron for twitter posting

Hi all

Working on a FREE online staking and rewards crypto rates comparator, I wanted to tweet stuff based on the data I collect. For example, an increase of a rate, or a new coin.

For this, when I retrieve the data, I populate a mongo collection with the text I want to share and the destination network (mainly twitter and reddit).

I also made a whole framework to have different variations of texts and, of course, markdown version (for reddit) and text version (for twitter)

Now, with this collection filled, I wanted to tweet those informations on the best schedule possible, as Buffer does.

To do this, I discovered Github Actions cron functionality.

name: optimal-cron-for-twitter

on:
  schedule:
    - cron: '58 17 * * MON'
    - cron: '49 17 * * MON'
    - cron: '32 13 * * TUE'
    - cron: '58 17 * * TUE'
    - cron: '49 21 * * TUE'
    - cron: '32 13 * * WED'
    - cron: '58 17 * * WED'
    - cron: '49 21 * * WED'
    - cron: '32 13 * * THU'
    - cron: '58 17 * * THU'
    - cron: '49 21 * * THU'
    - cron: '32 13 * * FRI'
    - cron: '58 17 * * FRI'
    - cron: '49 21 * * FRI'
    - cron: '32 13 * * SAT'
    - cron: '58 17 * * SAT'
    - cron: '49 21 * * SAT'
    - cron: '32 13 * * SUN'
    - cron: '58 17 * * SUN'
    - cron: '49 21 * * SUN'

jobs:
  cron:
    runs-on: ubuntu-latest
    steps:
      - name: optimal-cron-for-twitter
        run: |
          curl --request POST \
          --url 'https://stakingcrypto.io/api/cron/optimal-cron-for-twitter' \
          --header 'Authorization: Bearer ${{ secrets.CRON_APP_KEY }}'


Enter fullscreen mode Exit fullscreen mode

This basically will, every perfect time for posting, get back one tweet and post it to my twitter account @stakingcryptoio.

Github cron is setup for the GMT timezone and I adapted the best times for New York.

What about you, what schedule do you use to post on twitter optimally?

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay