Setting Up Dynacover with GitHub Actions - erikaheidi/dynacover GitHub Wiki

In this page you'll find a step-by-step guide on how to set up Dynacover to run with GitHub actions. Before getting started, make sure you have the following information available:

  • A registered application on dev.twitter.com with read and write access. Obtain the following 4 tokens from the application settings page:
    • Consumer / API Token (App token)
    • Consumer / API Secret (App secret)
    • Access Key (User token)
    • Access Secret (User secret)
  • Optional: a GitHub personal access token, only required if you want to showcase GitHub sponsors on your Twitter header.

For more information, check this tutorial.

Step 1: Create an empty GitHub repository

Start by creating a new empty GitHub repository, where you're going to set up the Dynacover workflow. Later on, you will be able to customize your header by committing a custom template / images to this repository.

Creating a new repository on GitHub

To speed things up, mark the checkbox to include a README file, that way a main branch will be automatically created and the repository will be ready to be cloned if you want to (not necessary for this guide, however - we'll use only the GitHub web UI).

Add a readme to the new repository

Step 2: Set up required repository secrets

Next, you'll need to set up your API keys. Go to Settings -> Secrets: Accessing repository secrets

Then, click on the New repository secret button on the top right.

Add repository secret

You'll need to add the following 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).

Once the secrets are set, you can create your workflow.

Step 3: Set up a Dynacover workflow

Next, go to Actions and click on the link that says set up a workflow yourself.

Create a new workflow

Rename the file to dynacover.yml and replace the boilerplate content with the following workflow, which will run Dynacover using default options every hour:

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/[email protected]
        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.DYNA_TWITTER_KEY }}
          DYNA_TWITTER_SECRET: ${{ secrets.DYNA_TWITTER_SECRET }}
          DYNA_TWITTER_TOKEN: ${{ secrets.DYNA_TWITTER_TOKEN }}
          DYNA_TWITTER_TOKEN_SECRET: ${{ secrets.DYNA_TWITTER_TOKEN_SECRET }}
          DYNA_GITHUB_TOKEN: ${{ secrets.DYNA_GITHUB_TOKEN }}

Once you're finished you can commit the file to the repository, and the workflow will be enabled. Commit Dynacover workflow to your repository

Step 4: Test the Workflow

Access the Actions tab of the repository where you've set up this workflow, select the Dynacover workflow on the left menu, and then click on the Run workflow button on the right to manually trigger the action.

Run action manually

Once the the action has finished running, check your Twitter profile to see if the header image was updated successfully.