Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to GreasyFork from github pipeline #1288

Open
alex1yaremchuk opened this issue Jul 14, 2024 · 4 comments
Open

Deploy to GreasyFork from github pipeline #1288

alex1yaremchuk opened this issue Jul 14, 2024 · 4 comments

Comments

@alex1yaremchuk
Copy link

Hi,
I played with webhooks and made it work with github triggering it automatically by itself on push (on tag creation it failed with 406).

But I expected to be able to trigger the webhook by myself from my pipeline after tests succeeded and after I checked the conditions for publishing (like certain tag name).

Haven't found any information on triggering GF webhooks from CI/CD pipeline.

@JasonBarnabe
Copy link
Collaborator

This is not currently supported.

There are two pieces that would be needed for this to work:

  1. Ability to understand a notification from the GitHub pipeline. (If you could provide a sample request that would be useful)
  2. Pulling the script from the correct place. Currently on webhook notifications, Greasy Fork is pulling from git, but already this breaks certain workflows where the script is not in git but is instead output by some build process.

@alex1yaremchuk
Copy link
Author

Thank you for the reply!

This is not currently supported.

There are two pieces that would be needed for this to work:

  1. Ability to understand a notification from the GitHub pipeline. (If you could provide a sample request that would be useful)

As for this - I thought we could trigger webhook with curl request.
I'll post below examples (chatGPT's help).

  1. Pulling the script from the correct place. Currently on webhook notifications, Greasy Fork is pulling from git, but already this breaks certain workflows where the script is not in git but is instead output by some build process.

Actually I could post the script content as part of the request, so there will be no need to look for it on github or somewhere else.

         payload='{
            "ref": "refs/tags/v2024-07-13",
            "before": "a4e6c9625545b2af76743283d1efb9b10504a03e",
            "after": "0000000000000000000000000000000000000000",
            "repository": {
              "id": 826871908,
              "name": "chatscroll",
              "full_name": "alex1yaremchuk/chatscroll",
              "private": false,
              "owner": {
                "name": "alex1yaremchuk",
                "email": "[email protected]"
              },
              "html_url": "https://github.com/alex1yaremchuk/chatscroll",
              "default_branch": "main"
            },
            "pusher": {
              "name": "alex1yaremchuk",
              "email": "[email protected]"
            },
            "created": false,
            "deleted": true,
            "forced": false
          }'
          response=$(curl -v -X POST -H "Content-Type: application/json" \
          -H "Authorization: Bearer githubsecret_here" \
          -d "$payload" \
          https://greasyfork.org/en/users/1280205-alex1yaremchuk/webhook)
          echo "Response code: $response"
          if [ "$response" -ne 200 ]; then
            echo "Deployment failed with response code $response"
            exit 1
          fi

previous version with passing file contents:

          script_content=$(cat src/main.js)
          response=$(curl -v -s -o /dev/null -w "%{http_code}" -X POST -H "Content-Type: application/json" \
          -H "Authorization: Bearer github_secret_here" \
          -d '{"event_type": "push", "script_content": "'"${script_content}"'"}' \
          https://greasyfork.org/en/users/1280205-alexander-yaremchuk/webhook)
          echo "Response code: $response"
          if [ "$response" -ne 200 ]; then
            echo "Deployment failed with response code $response"
            exit 1
          fi

@JasonBarnabe
Copy link
Collaborator

Do GitHub actions use the same secret token as webhooks do?

@alex1yaremchuk
Copy link
Author

Do GitHub actions use the same secret token as webhooks do?

If I understand your question right - we don't need to trigger actions, github does it by pipeline settings.

Github secret stores whatever we put into it, I put there GF token from webhook.
it's just a safe wrapper for a token to use in pipeline code.
Github substitutes it with a stored value on execution.

Sorry if I got into too much too obvious detail, I just wanted to clarify for mysef as well.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants