cbrgm / mastodon-github-action

Use this Action to send a toot (message) from a GitHub actions workflow to Mastodon.
Apache License 2.0
31 stars 1 forks source link

Missing protocol scheme #60

Open DanielBadura opened 1 month ago

DanielBadura commented 1 month ago

Hello 👋

we are currently getting an error: Error posting status: API call error: Post "/api/v1/statuses": unsupported protocol scheme ""

This error just started to happen about 2 Weeks ago. Last working job: https://github.com/patchlevel/event-sourcing/actions/runs/8687870377/job/23822282907 First failed job: https://github.com/patchlevel/event-sourcing/actions/runs/8734750142/job/23966065700

Between these 2 jobs the version was upgraded from v1 to v2. But i could find any BC-Break notices.

Worfklow file:

  mastadon:
    runs-on: ubuntu-latest
    steps:
      - uses: cbrgm/mastodon-github-action@v2
        if: ${{ !github.event.repository.private }}
        with:
          message: "New ${{ github.event.repository.name }} release ${{ github.event.release.tag_name }}! ${{ github.event.release.html_url }}"
        env:
          MASTODON_URL: ${{ secrets.MASTODON_URL }}
          MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}

I already re-checked the MASTODON_URL and this is https://phpc.social. And i also saw this issue here https://github.com/cbrgm/mastodon-github-action/issues/55 which suggest adding inheriting secret which seems not to be needed for our case, right?

I also saw another tool having the same problem: https://github.com/phpstan/phpstan-webmozart-assert/issues/180

cbrgm commented 1 month ago

Hi there @DanielBadura,

I'm sorry this causes you troubles. I believe the issue is that your MASTODON_URL is missing a https:// (e.g. https://mastodon.social) prefix, that's why the error occurs. #55 had the same issues.

cbrgm commented 1 month ago

The previous v1 version was written in Typescript and v2 is a rewrite in Go. Go's http package is more strict about url names. :-)

DanielBadura commented 1 month ago

I think you misunderstood me. I already re-checked the MASTODON_URL and re-set it with the value https://phpc.social but it still results in this error.

cbrgm commented 1 month ago

Got it. I'm checking what's wrong there, my assumption is I did a mistake parsing the environment variables the right way.

cbrgm commented 1 month ago

The environment variable parsing is fixed in v2.1.0 (https://github.com/cbrgm/mastodon-github-action/pull/61/files). The issue is not solved yet sadly. When I run

 podman run -e MASTODON_ACCESS_TOKEN="..." -e MASTODON_URL="https://mastodon.social" -e MASTODON_MESSAGE="Test Message" --rm -it ghcr.io/cbrgm/mastodon-github-action:v2

locally everything works as expected and I'm able to publish a message to Mastodon. But when I run the latest version in a workflow for some reason the secret values passed as environment variables to the container are somehow removed by GitHub (for security reasons?) (see: https://github.com/cbrgm/mastodon-github-action/actions/runs/9015989932/job/24771686465) .

That's pretty weird, there must be something happening when GitHub passes the environment variables defined in a workflow file to the container during the workflow run. The environment variables are basically there but the value is empty e.g. "", that's why the unsupported protocol error message pops up. I'd have to look into that why that's the case.

In case this is blocking you, please just pass the URL and the Access Token as arguments to the action, this works fine @DanielBadura .

- name: Send toot to Mastodon
  id: mastodon
  uses: cbrgm/mastodon-github-action@v2
  with:
    access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }} # access token
    url: ${{ secrets.MASTODON_URL }} # https://example.social
    message: "Hello from GitHub Actions!"