From 262828a3e1fc97d8cebc5026e74cd256573dc05b Mon Sep 17 00:00:00 2001 From: cbrgm Date: Thu, 9 May 2024 12:21:31 +0200 Subject: [PATCH 1/2] fix: fix parsing arguments as environment variables --- cmd/mastodon-github-action/main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/mastodon-github-action/main.go b/cmd/mastodon-github-action/main.go index 44d0fce..4e310f1 100644 --- a/cmd/mastodon-github-action/main.go +++ b/cmd/mastodon-github-action/main.go @@ -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. From 75ccf580fea9ec1f11f07aa620cd88b4390ac1b3 Mon Sep 17 00:00:00 2001 From: cbrgm Date: Thu, 9 May 2024 12:25:17 +0200 Subject: [PATCH 2/2] add example workflow --- .github/workflows/example-workflow-envs.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/example-workflow-envs.yml diff --git a/.github/workflows/example-workflow-envs.yml b/.github/workflows/example-workflow-envs.yml new file mode 100644 index 0000000..9e163c1 --- /dev/null +++ b/.github/workflows/example-workflow-envs.yml @@ -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