0

i want to run a workflow with no user interaction needed in the command line with ubuntu. I installed gh on my ec2 instance and already logged in successfully without any user interaction needed. Can i do the same with the gh workflow run?

I only tried the manual version which did work:

gh workflow list:
Node.js CI active 45311919

and then:

gh workflow run
(selected: Node.js CI (node.js.yml)

and then checked with this and it worked:

gh run list --workflow=node.js.yml

I am creating a cloud-init file so i cant accept user interactions. I need everything without this. Can i in addition to that let the cloud-init file stop the next commands in my cloud-init until this run is finished?

workflow file:

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]
  workflow_dispatch:

jobs:
  build:

    runs-on: self-hosted

    strategy:
      matrix:
        node-version: [16.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
        token: ${{ secrets.TOKEN_NAME }}
    - run: npm ci
    - run: npm run build --if-present
crvxッ
  • 60
  • 7
  • How's your workflow configured? Please include the `on:` section of your GitHub Actions workflow in your question. The docs of [gh workflow run](https://cli.github.com/manual/gh_workflow_run) mentions that it should be configured as `workflow_dispatch` to be run with `git workflow run` command. – Azeem Jan 26 '23 at 11:10
  • Also, see [workflow_dispatch](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch). – Azeem Jan 26 '23 at 11:13
  • You mentioned that you have already tested it and it worked. You can simply add that command directly after your login sequence and it should work there too. Example: `gh workflow run node.js.yml` (https://cli.github.com/manual/gh_workflow_run) – Azeem Jan 26 '23 at 11:20
  • Hi Azeem, i want to do it like this: `gh workflow run --name to start workflow`. The `workflow_dispatch` is already added. But i have to select the workflow file if i do this option: `git workflow run`. As i mentioned, i would like to have 0 user interaction. BTW: in the question i added the workflow file @Azeem – crvxッ Jan 26 '23 at 11:23
  • Try: `gh workflow run node.js.yml` – Azeem Jan 26 '23 at 11:27
  • Regarding your query about waiting for a run to complete, please take a look at [gh run](https://cli.github.com/manual/gh_run) command. It has [gh run watch](https://cli.github.com/manual/gh_run_watch) command that you can use. You may need to experiment with `gh run list` and `gh run watch` from the command line first to make it right according to your use case. – Azeem Jan 26 '23 at 11:33
  • Good. No worries. :) You had a typo. Questions that are not reproducible due to typos are closed. I'm flagging it for close. No need to add an answer. Cheers! – Azeem Jan 26 '23 at 11:36
  • Refer to the [GitHub CLI's manual](https://cli.github.com/manual/) for commands. Examples are also there. Good luck! – Azeem Jan 26 '23 at 11:39

0 Answers0