Trigger github actions from external tools

Поделиться
HTML-код
  • Опубликовано: 2 ноя 2024

Комментарии • 23

  • @maisam.alatrach
    @maisam.alatrach Год назад

    You are ammazing, I was strugling to undsestand it before.

  • @debapriyabasu6188
    @debapriyabasu6188 3 года назад +1

    Hi Nice Demo! I have one query. Suppose I have one workflow_dispatch pipeline set in one of our organisation repo. I want to create some trigger point so that other people who dont have write access in my working repo can trigger the yml file from different repository. Can I trigger that yml file from some other repo of same organisation, if yes then how I can do that?

    • @merowareinstance
      @merowareinstance  3 года назад

      You will still have a token dependency. But basically you’ll need a token that has access to your repo. Then you would create a workflow in the secondary repo that others have access to, so they can manually trigger their own new workflow with whatever events they want. That repo can then post a workflow dispatch event or a repository dispatch event using the GitHub api and the token that has access to your repo. You can add this token in organization secrets or repo secrets of secondary repo so that no one else knows it. Once the api call is made, then the event will trigger your repos workflow.
      The video goes through repository dispatch, but you can also use api call from the following doc to trigger a workflow dispatch
      docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event

  • @yashkotti7826
    @yashkotti7826 Год назад

    Hi how can we get the status of the workflow we triggered with api. We can't get it in postman I want the status of the triggered workflow with api

  • @serkancolak
    @serkancolak Год назад

    great video

  • @SAMRATBASRA
    @SAMRATBASRA Год назад

    great work, one question, can we trigger workflow when there is commit in another repo, supoose i have workflow yaml file in repo1 and i want to trigger it when there is commit in repo2 ?

    • @kalathti
      @kalathti Год назад

      repository dispatch event in github docs

  • @DeepakSharma-py7bd
    @DeepakSharma-py7bd 3 года назад +1

    Need help to get time left for workflow and run job via a api,I am doing this for GitHub Windows RDP which works only for 6:0 HOURS

    • @merowareinstance
      @merowareinstance  3 года назад

      What issue are you exactly running into?

    • @DeepakSharma-py7bd
      @DeepakSharma-py7bd 3 года назад

      @@merowareinstance sir, I want to run workflow job via "post" Api (api GitHub) and want to get the time period of that workflow-job via "get" .I am beginner and need help in running a github action via get and post

    • @DeepakSharma-py7bd
      @DeepakSharma-py7bd 3 года назад

      Want to run workflow /jobs (action) via rest api (javascript)

  • @andrewobrigewitsh
    @andrewobrigewitsh 3 года назад +1

    I've been looking all over for this. Thank you!!!!
    I'm now trying to read in input passed into the body, do you have a video on that?

    • @merowareinstance
      @merowareinstance  3 года назад

      I'll think about creating a video to go into more detail on how to send a payload and read it from github actions. But here is an example github actions workflow that you can look at for reference github.com/meroware/example-event-dispatcher-workflows/blob/master/.github/workflows/all-in-one.yaml
      The sample body I sent on POST request was
      {
      event_type = "run-done-allinone";
      client_payload: { // JSON payload with extra information
      command: "done", // I picked this attribute, for your action you can use whatever names/keys you want
      }
      }
      Then I read the data I sent in the workflow that was triggered through posting about body through repository dispatch as follows
      ${{ github.event.client_payload.command }}
      Good luck,

  • @andriimykytiuk9396
    @andriimykytiuk9396 3 года назад

    Hi! And can we run the github flow from Slack? Can you please give an example? On slash command settings there's only URL field for POST. How can we pass the payload? Thanks

    • @merowareinstance
      @merowareinstance  3 года назад +1

      Normally when you are building a slash command for slack, you have to interact with a custom backend application that you build. This way you can create interactive forms with slack users or just provide the ability to send a generic trigger to the backend application to do some other work. Once you have all the data provided from the interaction of a slack user with your slash command, then you can use this in your backend application to make api calls to Github Actions.
      Here is a good resource to get you started api.slack.com/interactivity/slash-commands
      Maybe i'll work on a tutorial on how to do this in a future video 😁

  • @rikomamadesu
    @rikomamadesu Год назад

    where can I get the github_token?

  • @ikmalilbirri8895
    @ikmalilbirri8895 3 года назад

    Hello Meroware,
    thanks for this tutorial. I have tried this. the result is a success when on the postman. and I try to create we static webpage when I access it with a URL then will be triggered that. I try on next.js and success triggering. i want to deploy on GitHub pages but I always get an error authorization. what should I do?

    • @merowareinstance
      @merowareinstance  3 года назад

      You should be able to just create a github actions workflow that runs the build process and merges to main into directory gh-pages. Just make sure your github action ignores running the build on directory gh-pages or it will run forever 🤣
      Since you are merging to main, you shouldn't need a new token, but you do need to make sure the git setup is done properly so that you can create a commit and merge.
      I'll see if i can create a tutorial on this to explain it more in detail 😁

  • @Norfeldt
    @Norfeldt 3 года назад +1

    Nice demonstration!
    Do you know if you can have a github action do a commit with some of the generated results?
    I got this idea of having a visual test in the CI and commit the images generated (and have some sort of mechanism to ensure it does not get stuck in an eternal loop since a commit would trigger the github action to re-run).
    (A cherry on the top would be having a bot post the images that does not pass the tests.)

    • @merowareinstance
      @merowareinstance  3 года назад +1

      thank you very much, glad you enjoyed it.
      Yes you can do it in multiple ways. One example is by either filtering by branch or by paths. If you ignore by paths then this will not trigger the pipeline on the files pushed to that directory. Below is an example, good luck
      e.g
      .github/workflows --> holds your workflows
      src/ --> holds your source files
      generated/ --> holds your generated images (This directory path will be ignored with the below code)
      on:
      push:
      paths-ignore:
      - 'generated/**'
      Once you build and push to master. Then you can add a filter by directory and ignore generated dir

    • @Norfeldt
      @Norfeldt 3 года назад +1

      @@merowareinstance thank you so much for this great tip. I will give it a try.
      How would you go about commiting (and pushing) some files generated by the GitHub action? Any tips/hints/links would be appreciated.

    • @merowareinstance
      @merowareinstance  3 года назад +1

      You can use action/checkout that allows you to checkout the code and create a commit. The nice thing is that the action also generates a one time github token that allows you to push into the same repository and invalidates it after the workflow is done. Here is the link to the repo and example
      github.com/actions/checkout#push-a-commit-using-the-built-in-token
      It is the last section named `Push a commit using the built-in token`, good luck 😄

    • @Norfeldt
      @Norfeldt 3 года назад +1

      @@merowareinstance thanks again dude. You are great