Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ironsource/action-trigger-workflow

Trigger GitHub action workflow file from another repo and wait until it will be done.
https://github.com/ironsource/action-trigger-workflow

github-action github-actions

Last synced: 26 days ago
JSON representation

Trigger GitHub action workflow file from another repo and wait until it will be done.

Awesome Lists containing this project

README

        

# action-trigger-workflow
Trigger GitHub action workflow file from another repo and wait to it will be done.

## Example usage

Here is an example setup of this action:

1. Create a `.github/workflows/ci-initiator.yml` file in your GitHub repo.
2. Add the following code to the file.

```yml
name: CI-Initiator

on:
push:

jobs:
startCI:
runs-on: ubuntu-latest
steps:
- name: Generate Unique runer id
id: vars
run: |
echo ::set-output name=sha_short::${GITHUB_SHA::7}
echo ::set-output name=uuid::${{github.ref_name}}:${GITHUB_SHA::7}:${GITHUB_RUN_ID}

- name: Trigger Remote Action
uses: AndyKIron/trigger-action-workflow@v1
with:
owner: REMOTE_REPO_OWNER # remote repository owner
repo: REMOTE_REPO_NAME #remote repository name
github_token: ${{ secrets.PAT_TOKEN }} # your token
workflow_file_name: ci.yml # remote action workflow file name
job_uuid: "${{ steps.vars.outputs.uuid }}"
inputs: '{ "branch_name": "${{github.ref_name}}", "user": "${{github.actor}}", "uuid": "${{ steps.vars.outputs.uuid }}", "sha": "${{ steps.vars.outputs.sha_short }}", "event_name": "${{github.event_name}}", "event_action": "${{github.event.action}}"}'
```

### Inputs (with)

| Variable | | Purpose |
|--------------------|----------|--------------------------------------------------------------------------------------------------------|
| owner | required | Remote repository owner name |
| repo | required | Remote repository name |
| github_token | required | Generated Personal Access Token |
| workflow_file_name | required | Remote action workflow filename (with .extension) |
| job_uuid | required | Unique string to identify the running remote action workflow |
| inputs | required | JSON for remote action inputs |
| ref | false | The reference of the workflow run. The reference can be a branch, tag, or a commit SHA. Default "main" |
| wait_interval | false | The number of seconds delay between checking for result of run. Default - 10 sec |
| propagate_failure | false | Fail current job if downstream job fails. Default - true |
| wait_workflow | false | Wait for workflow to finish. Default - true |
| monitored_job_name | false | Job name to monitor and return job id for.|

### Outputs:
| Variable | Description |
|-------------------|----------|
| workflow_id | The ID of the workflow that was triggered by this action |
| workflow_url | The URL of the workflow that was triggered by this action |
| job_id | The Job Id of the requested job to monitor, if none provided then null |

3. On remote target action workflow file (ci.yml for example) you need add needed inputs
4. And one (first) stem must have "name:" with "job_uuid"

```yml
name: CI-Starter

on:
workflow_dispatch:
inputs:
branch_name:
required: true
user:
required: true
job_uuid:
required: true

jobs:
# --- Do Job Initiator for ci_initiator can find it in from API in jpb name
ci-init:
name: 'CI-Init::${{ github.event.inputs.job_uuid }}'
runs-on: ubuntu-latest
steps:
- run: |
echo "Start CI for ${{ github.event.inputs.user }}:${{ github.event.inputs.job_uuid }}"
...
...
...
```