presence

Format and post a thread with GitHub Actions

This process is split into two steps, each served by a different GitHub Action:

  1. instantiator/presence/format-thread - formats thread content for each social network specified
  2. instantiator/presence/post-thread - posts a formatted thread to social networks specified (using credentials specified)

Output from the first step is a fully formatted set of threads, one for each network type. This can then be passed into the second step as an input alongside social network credentials to send the posts.

For a worked example, see the sample workflow found in:

Formatting

Use the instantiator/presence/format-thread action:

- uses: actions/checkout@v4
- name: Format sample thread
  id: format-thread
  uses: instantiator/presence/format-thread@main
  with:
    networks: 'Console,AT'
    input-file: 'SampleData/SimpleThread.md'

In this example, the formatter prepares a thread found in a file: SimpleThread.md

The id field is essential if you wish to pass the output from this step on, eg. as $

Here the inputs, under with: provide key information:

Alternatively, provide content directly rather than from a file:

    input-format: 'MD'
    input-content: |
      This is a simple thread.

      With two posts.

input-content and input-file are mutually exclusive. input-format is required if input-content is provided.

For information about preparing content, see:

Posting

Use the instantiator/presence/post-thread action:

- name: Post sample thread to console
  id: post-thread
  uses: instantiator/presence/post-thread@main
  with:
    thread: $

The id field is optional, but helpful if you want to refer to its output later, eg. as $

This step will also need some configuration to tell it about network credentials…

Configuration options

You should provide credentials for all networks you intend to post to.

It is recommended to store your social network credentials in GitHub Actions Secrets, to prevent their being discovered / abused.

For information about configuration keys, see: Network specific configuration

NB. If you have not provided a thread for each social network configured, the posts that can be sent will be sent, but the step will report failure.

There are several ways to provide configuration:

  1. Provide all secrets as JSON (simplest option)
  2. Craft the JSON configuration (better control of your secrets)
  3. As environment variables (probably easiest to read)

1. Provide all secrets as JSON (simplest option)

If you’re confident you have no other important secrets in your repository, it’s simplest to provide all your secrets as a JSON object.

This is the approach shown in: on-push-test-actions.yml

It’s also the option that will require the least maintenance if you intend to add more credentials/secrets in future.

with:
    thread: $
    config: $

2. Craft the JSON configuration (better control of your secrets)

Provide a single config input containing a JSON dictionary of all configuration.

This is a little more complex, but allows you much better control of which information is passed to the action.

with:
    thread: $
    config: "{ \"PRESENCE_ACCOUNTS\": \"TEST0,TEST1\", \"TEST0_CONSOLE_PRINTPREFIX\": \"[TEST0-GHA]\", \"TEST1_AT_ACCOUNTNAME\": \"$\", \"TEST1_AT_APPPASSWORD\": \"$\" }"

3. Provide environment variables (probably easiest to read)

Pass individual secrets as environment variables.

Similarly, this grants you item-by-item control of which information is passed to the action.

with:
    thread: $
env:
    PRESENCE_ACCOUNTS: "TEST0,TEST1"
    TEST0_CONSOLE_PRINTPREFIX: "[TEST0-GHA]"
    TEST1_AT_ACCOUNTNAME: $
    TEST1_AT_APPPASSWORD: $