Skip to content

Commit

Permalink
fix: fix parsing arguments as environment variables (#61)
Browse files Browse the repository at this point in the history
* fix: fix parsing arguments as environment variables

* add example workflow
  • Loading branch information
cbrgm committed May 9, 2024
1 parent 1c53215 commit 3737c0d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/example-workflow-envs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Send Mastodon Message (Environment Variables)

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Send toot to Mastodon
id: mastodon
uses: cbrgm/mastodon-github-action@main
with:
message: "Hello from GitHub Actions!"
visibility: "private" # default: public
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }} # access token
MASTODON_URL: ${{ secrets.MASTODON_URL }} # https://example.social
16 changes: 8 additions & 8 deletions cmd/mastodon-github-action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ type MastodonStatus struct {

// ActionInputs collects all user inputs required for posting a status.
type ActionInputs struct {
URL string `arg:"--url,required" env:"MASTODON_URL"` // Mastodon instance URL.
AccessToken string `arg:"--access-token,required" env:"MASTODON_ACCESS_TOKEN"` // User access token for authentication.
Message string `arg:"--message,required" env:"MASTODON_MESSAGE"` // The status message content.
Visibility string `arg:"--visibility" env:"MASTODON_VISIBILITY"` // Visibility of the status.
Sensitive bool `arg:"--sensitive" env:"MASTODON_SENSITIVE"` // Flag to mark status as sensitive.
SpoilerText string `arg:"--spoiler-text" env:"MASTODON_SPOILER_TEXT"` // Additional content warning text.
Language string `arg:"--language" env:"MASTODON_LANGUAGE"` // Language of the status.
ScheduledAt string `arg:"--scheduled-at" env:"MASTODON_SCHEDULED_AT"` // Time to schedule the status.
URL string `arg:"--url,required, env:MASTODON_URL"` // Mastodon instance URL.
AccessToken string `arg:"--access-token,required, env:MASTODON_ACCESS_TOKEN"` // User access token for authentication.
Message string `arg:"--message,required, env:MASTODON_MESSAGE"` // The status message content.
Visibility string `arg:"--visibility, env:MASTODON_VISIBILITY"` // Visibility of the status.
Sensitive bool `arg:"--sensitive, env:MASTODON_SENSITIVE"` // Flag to mark status as sensitive.
SpoilerText string `arg:"--spoiler-text, env:MASTODON_SPOILER_TEXT"` // Additional content warning text.
Language string `arg:"--language, env:MASTODON_LANGUAGE"` // Language of the status.
ScheduledAt string `arg:"--scheduled-at, env:MASTODON_SCHEDULED_AT"` // Time to schedule the status.
}

// StatusResponse models the response returned by Mastodon after posting a status.
Expand Down

0 comments on commit 3737c0d

Please sign in to comment.