callmekatootie / carbonate

Github Action to format fenced code blocks in github issues as images. Originally created as part of DEV Github Actions hackathon: https://dev.to/callmekatootie/jazz-up-the-code-blocks-in-github-issues-52e6
https://github.com/marketplace/actions/carbonate
MIT License
237 stars 6 forks source link
action carbon formatter imgur prettier

Carbonate

Jazz up the code blocks in your issues. Generate beautiful images for them to make it easier to follow. Meant to be used as a Github Action.

BEFORE

AFTER

First appeared at: https://stackoverflow.com/a/61269447/2104976

Features

The workflow of this action is as follows:

Additionally, it

Not supported (yet)

Advantages of code images over code blocks

Pre-requisites

Register your application with Imgur to get a client_id. You will pass this as input to the action.

Usage

on:
  issue_comment:
    types: [created]
  issues:
    types: [opened]

jobs:
  carbonate:
    runs-on: ubuntu-latest
    name: Generate beautiful images for code blocks present in issues
    steps:
      - name: Generate beautiful images for code blocks present in issues
        uses: callmekatootie/carbonate@v1.0.2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          imgur-client-id: ${{ secrets.IMGUR_CLIENT_ID }}

More inputs are available. See below.

Inputs

github-token

This is the environment variable GITHUB_TOKEN.

imgur-client-id

The client_id that you obtained after registration with imgur. The action will be carrying out anonymous uploads. Required.

use-prettier

The action can use Prettier to format the code block before the image is generated. Set this input's value to the String 'true' if you want to use it or to the String 'false' otherwise. Default value is 'true'

prettier-parser

This input is only read if use-prettier input is 'true'. You will specify the parser that you want Prettier to use for formatting the code. Default value is 'babel'

prettier-options

This input is only read if use-prettier input is 'true'. You can specify the format options to use with Prettier. You need to pass the options object as a JSON string. If none is passed, the action will fall back to Prettier's default format options.

carbon-options

You can specify the Carbon image generation configuration options. See this for a list of supported options. You need to pass the options object as a JSON string. If none is passed, the action will use the options defined in the constants.js file.

References