Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Pilot Lvl 2
Message 21 of 66

Re: GitHub Actions Manual Trigger / Approvals


@SeanFeldman wrote:

having no manual triggers/approvers is a step back


 

You can have manual approvers if you have a workflow that is attached to the issue_comment type.

For example, the following workflow would run whenever someone would comment "OK to test" in a PR (which is internally seen as a type of issue by GitHub):

 

name: Run on demand

on:
  issue_comment:
    types: [created, edited]

jobs:
  ondemand:
    runs-on: ubuntu-latest
    if: github.event.comment.body == 'OK to test'
    
    steps:
      - name: Hello world
        run: echo Hello world, I was run on demand by ${GITHUB_ACTOR}

Additionally, you can also restrict which users are allowed to trigger a workflow this way, by doing checks against the github.event.comment.user.login variable or the GITHUB_ACTOR environment variable.

Highlighted
Copilot Lvl 3
Message 22 of 66

Re: GitHub Actions Manual Trigger / Approvals

does this still work for you? i've attempted to use this solution and my workflows are not being triggered by posting a comment anywhere - issue or PR, even while not including the "conditional" statement

 

e.g.:

name: deploy_to_channel_on_demand

on:
  pull_request_review_comment:
    types: [created, edited]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: logging
        run: echo "$GITHUB_REF"
Highlighted
Pilot Lvl 2
Message 23 of 66

Re: GitHub Actions Manual Trigger / Approvals

Hi @uladkasach , you have to use issue_comment for posting a Pull Request comment instead of using pull_request_review_comment to trigger the workflow when there is a pull request comment. 

name: deploy_to_channel_on_demand

on:
  issue_comment:
    types: [created, edited]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: logging
        run: echo "$GITHUB_REF"

 

Highlighted
Copilot Lvl 2
Message 24 of 66

Re: GitHub Actions Manual Trigger / Approvals

It doesn't work for the branch in which I added workflow includes this trick (the workflow isn't in master), action doesn't trigger.

Highlighted
Copilot Lvl 2
Message 25 of 66

Re: GitHub Actions Manual Trigger / Approvals

 

on:
  issue_comment:
    types: [created, edited]

jobs:
  build:
    name: Build
    runs-on: macos-latest
    if: github.event.comment.body == 'build ios'
    steps:
      - name: Fetch issue info
        uses: octokit/request-action@v2.x
        id: get_issue_info
        with:
          route: GET ${{ github.event.issue.url }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Parse issue info
        id: parse_issue_info
        uses: gr2m/get-json-paths-action@v1.x
        with:
          json: ${{ steps.get_issue_info.outputs.data }}
          pull_request_url: "pull_request.url"
      - name: Fetch PR info
        uses: octokit/request-action@v2.x
        id: get_pr_ref
        with:
          route: GET ${{ steps.parse_issue_info.outputs.pull_request_url }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Parse PR info
        id: parse_pr_info
        uses: gr2m/get-json-paths-action@v1.x
        with:
          json: ${{ steps.get_pr_ref.outputs.data }}
          ref: "head.ref"
      - uses: actions/checkout@v1
        with:
          ref: ${{ steps.parse_pr_info.outputs.ref }}

This solution extracts the branch from the associated PR in which the comment was entered.

 

Highlighted
Copilot Lvl 3
Message 26 of 66

Re: GitHub Actions Manual Trigger / Approvals

Deliverybot (using github deployments) might be something that solves this issue. I let deliverybot automatically deploy to the staging server, check if everything is working and manually deploy to producting using deliverybot. 

Highlighted
Copilot Lvl 3
Message 27 of 66

Re: GitHub Actions Manual Trigger / Approvals

This definitely looks promising as a stop-gap, but I would love to see this as native GitHub functionality. Especially if DeliveryBot becomes a paid product once it is out of beta. I couldn't find any information on the beta / pricing status for DeliveryBot though.

 

However, it does look like this will meet our requirements for triggering deployments in the meantime. However, from what I can tell, the approval gate use case is still not covered by this tool.

Highlighted
Copilot Lvl 3
Message 28 of 66

Re: GitHub Actions Manual Trigger / Approvals

https://deliverybot.dev/docs/guide/6-promotion/
Documentation isn't great, it also doesn't work with caching yet, so I'm just using on: push again.

Highlighted
Pilot Lvl 1
Message 29 of 66

Re: GitHub Actions Manual Trigger / Approvals

This is my "ChatOps" for GitHub Actions solution. It may be suitable for some use cases.

 

https://github.com/peter-evans/slash-command-dispatch

 

Highlighted
Ground Controller Lvl 2
Message 30 of 66

Re: GitHub Actions Manual Trigger / Approvals

All of these solutions does not satisfy the absolute need of feature available from GitHub itself.

Not only gateing we should be able to setup release pipeline separately from build pipeline.

Currently the "build" step and "release" step should be in the same action.yml file, boz they share the artifacts and we can not spit them.

This kind of tight coupling is limiting the ability to release different artifacts to different environments.

 

Most of the time "Canary" environment move faster than "Insider/Staging" and staging move fater than "production".

 

The github action in the current form is best fit for someone who follows "commit to straight prod" paradigm.