DEV Community

Erika Heidi
Erika Heidi

Posted on • Updated on

Dynamic Twitter header images with Dynacover GitHub Action!

My Workflow

Earlier this year, I've built a command-line application to generate dynamic Twitter header images showing latest followers and GitHub sponsors, called Dynacover. I shared the full tutorial on how I built this here on DEV.

screenshot showing the dynamic header image on my Twitter profile

With the GitHub Actions Hackaton coming up, and considering it's also possible to run GH Actions on schedule, I thought it would be a very interesting challenge to containerize this application and package it as a GH Action. It took me a couple weeks to figure out how to optimize the build and how to allow users to customize their banner templates, but today I was finally able to wrap everything up.

The Dynacover GitHub Action is now published to the Marketplace and can be used by anyone with a GitHub account.

The action files are available in this repository:

GitHub logo erikaheidi / dynacover-actions

GitHub Actions to run Dynacover

Dynacover Action

Dynacover is a CLI application that dynamically generates Twitter header images showcasing your latest followers and/or GitHub Sponsors This action runs Dynacover to update the Twitter header image of the account linked through the secret keys that must be previously defined as repository secrets.

Please refer to erikaheidi/dynacover for more details on how Dynacover works, what are the customization options, and how to create custom templates.

Requirements

You'll need to set up your Twitter API credentials and user tokens using repository secrets, on the same repository you set up your action workflow. The GitHub token is optional, only required if you want to use one of the covers that showcase GitHub Sponsors.

Secrets

  • DYNA_TWITTER_KEY: your Twitter application consumer key or App Key.
  • DYNA_TWITTER_SECRET: your Twitter application consumer secret or App Secret.
  • DYNA_TWITTER_TOKEN: your personal user token.
  • DYNA_TWITTER_TOKEN_SECRET: your personal user token secret.

Submission Category:

Wacky Wildcards

Yaml File or Link to Code

You'll need to set up your Twitter API credentials and user tokens using repository secrets, on the same repository
you set up your action workflow. The GitHub token is optional, only required if you want to use one of the covers that showcase GitHub Sponsors.

Secrets

  • DYNA_TWITTER_KEY: your Twitter application consumer key or App Key.
  • DYNA_TWITTER_SECRET: your Twitter application consumer secret or App Secret.
  • DYNA_TWITTER_TOKEN: your personal user token.
  • DYNA_TWITTER_TOKEN_SECRET: your personal user token secret.
  • DYNA_GITHUB_TOKEN (optional): your GitHub personal token (for pulling GitHub Sponsors).
name: Update Twitter Header Image with Dynacover
on:
  schedule:
    - cron: "0 * * * *"
  workflow_dispatch:
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          path: 'dynacover_custom'
      - name: 'Update Dynacover image and upload to Twitter'
        uses: erikaheidi/dynacover-actions@v4.2
        env:
          # Uncomment and change accordingly to customize your cover
          #DYNA_DEFAULT_TEMPLATE: dynacover.json
          #DYNA_TEMPLATES_DIR: ${{ github.workspace }}/dynacover_custom
          #DYNA_IMAGES_DIR: ${{ github.workspace }}/dynacover_custom
          DYNA_TWITTER_KEY: ${{ secrets.TW_CONSUMER_KEY }}
          DYNA_TWITTER_SECRET: ${{ secrets.TW_CONSUMER_SECRET }}
          DYNA_TWITTER_TOKEN: ${{ secrets.TW_USER_TOKEN }}
          DYNA_TWITTER_TOKEN_SECRET: ${{ secrets.TW_USER_TOKEN_SECRET }}
          DYNA_GITHUB_TOKEN: ${{ secrets.DYNA_GITHUB_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

For a detailed step by step guide on how to set this up, check out this Dynacover wiki page. You can set up your workflow using the GitHub web interface, no coding needed!

To see this workflow in action using a custom template and cover, check my own erikaheidi/github-actions repository, where I have my own Dynacover set up.

Discussion (2)

Collapse
bobbyiliev profile image
Bobby Iliev

Super cool! Just set that up for my Twitter cover

Bobby Iliev Twitter cover image

I've added it to my GitHub profile repo:

Hello there
My name is Bobby Iliev


Github YouTube Channel Subscribers Twitter Follow YouTube Channel Views

I'm a Linux DevOps Engineer working in Sofia, Bulgaria.

BIO
  • ⚙️   I use daily: .sh, .php, .js, .html, .css, .blade.php, .sql
  • 🌍   I'm mostly active within the DigitalOcean Community and DevDojo
  • 🌱   Learning all about Open Source
  • 💬   Ping me about linux, bash, laravel, development, devops
  • ⚡️   Fun fact: I'm a big fan of cats 🐱‍💻
  • 📫   How to reach me via email, twitter, devdojo, dev.to or linkedin.
Books

RECENT DEVDOJO POST

Collapse
erikaheidi profile image
Erika Heidi Author

oooh that's awesome, thanks for sharing Bobby!