Open nhoizey opened 1 year ago
Previous attempt of developing a composite action:
name: "Composite JSON Feed to Mastodon"
description: "Create messages (toots) on Mastodon from a JSON Feed items"
author: "Nicolas Hoizey"
branding:
icon: "cast"
color: "green"
inputs:
feedUrl:
description: "URL of the JSON Feed to fetch"
required: true
mastodonInstance:
description: "The root URL of the Mastodon instance where the toot should be created"
required: true
mastodonToken:
description: "Your access token for the Mastodon API, get it from /settings/applications/new"
required: true
nbTootsPerItem:
description: "Number of toots that can be created from the same item"
default: 1
globalDelayToots:
description: "Delay (in minutes) between any toot from this feed (default: 1 day)"
default: 1440
delayTootsSameItem:
description: "Delay (in minutes) between any toot from this feed for the same item (default: 90 days)"
default: 129600
cacheFile:
description: "Path to the JSON file caching data from the feed and toots"
default: ".cache/jsonfeed-to-mastodon.json"
cacheTimestampFile:
description: "Path to the JSON file caching the timestamp of the last toot"
default: ".cache/jsonfeed-to-mastodon-timestamp.json"
outputs:
tootUrl: # output will be available to future steps
description: "URL to the latest toot created"
runs:
using: "composite"
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Set up Node.js ⚙️
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install dependencies 📦
run: npm ci
shell: bash
- name: JSON Feed to Mastodon 🦣
env:
RUNNER_TEMPORARY_DIRECTORY: ${{ runner.temp }}
run: node ./dist/index.js
shell: bash
with:
feedUrl: ${{ inputs.feedUrl }}
mastodonInstance: ${{ inputs.mastodonInstance }}
mastodonToken: ${{ inputs.mastodonToken }}
nbTootsPerItem: ${{ inputs.nbTootsPerItem }}
globalDelayToots: ${{ inputs.globalDelayToots }}
delayTootsSameItem: ${{ inputs.delayTootsSameItem }}
cacheFile: ${{ inputs.cacheFile }}
cacheTimestampFile: ${{ inputs.cacheTimestampFile }}
- name: Pull any changes 📥
run: git pull
shell: bash
- name: Commit and push 📤
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(cache): update Mastodon cache file (automated)"
file_pattern: "*.json"
skip_fetch: false
I solved this exact problem by running my JS code manually as a step and adding necessary inputs as environment variables formatted in a way getInput
from @actions/core
picks them up just fine (i.e. all uppercase letters prefixed by INPUT_
) -- https://github.com/lwojcik/github-action-feed-to-social-media/blob/main/action.yml
I can contribute a relevant PR to your action, please let me know if you're interested.
A composite action could maybe take care of the checkout and commit/push steps, so this:
Could become this:
But composite actions have some limits.