Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Updated README, action name, add branding
Browse files Browse the repository at this point in the history
  • Loading branch information
baski-accenture committed Apr 7, 2021
1 parent 606ded2 commit 647f9ab
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 13 deletions.
61 changes: 50 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

_Assumption_ : You are managing cloud infrastructure with terraform remote state in "github actions"

Wait-For-Other-Pipelines is a GitHub Action to enable parallel runs to wait on a step so they will
not fail to acquire remote state lock.

This action is tested to run on ubuntu.

```
jobs:
build:
runs-on: ubuntu-latest
```

If the same workflow is used by multiple branches or there are multiple commits in the same branch chances are that
the workflow runs after 1st run might get failed due to not being able to acquire lock on terraform remote state as
1st run is already having the lock in place.
Expand All @@ -13,13 +26,48 @@ By doing so the consequent runs will wait till the previous runs are complete.
But when a previous completed run is rerun while there are newer runs in the queue, the newer runs will wait till the rerun is complete.
The rerun will also wait for any run which has already crossed the wait step.

## Action Inputs

<table>
<thead>
<tr>
<th>Input</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>

<tr>
<td>step-name</td>
<td>Yes</td>
<td>
Name of the step where the action is used.
</td>
</tr>

</table>

## Examples

The example below shows how the `Wait-For-Other-Pipelines` action can be used
to wait for other pipeline runs.

```
- name: Wait For Other Pipelines
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: otto-de/[email protected]
with:
step-name: "Wait For Other Pipelines"
```

# Below are the steps to achieve parallel jobs running in github workflow to wait on a particular step

1. Name the step as needed. For example: "Wait for other pipelines"
2. Use the action "otto-de/github-actions-wait@v1" with the step name as input as shown below.
2. Use the action "otto-de/github-actions-wait@v1.0" with the step name as input as shown below.
The argument to the script should be the same as step name.
Accept the env defined in the sample shown below as it is, since the env set is used to make API calls to github
3. Place the wait step/s in the workflow in such places so that the following steps should not run in parallel by other jobs.
3. Place the wait step/s in the workflow in such a place so that the following steps should not run in parallel by other jobs.
An example of this wait step could be the terraform apply steps which use remote state lock feature. If 2 jobs try to use same remote state the 2nd job will fail.
4. How the script works is as below:
1. If the number of running jobs is 1, then there is no other job running, there will not be any waiting
Expand All @@ -30,15 +78,6 @@ Accept the env defined in the sample shown below as it is, since the env set is
1. If wait step is crossed for any of the newer jobs, then wait the current rerun job till the already running newer job to finish
2. If no wait step is crossed for any of the newer jobs, rerun will continue execution without waiting

```
- name: Wait
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: otto-de/github-actions-wait@v1
with:
step-name: "Wait"
```

# Future work

1. Multiple wait steps
Expand Down
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: 'Wait'
description: 'Wait'
name: 'Wait-For-Other-Pipelines'
description: 'Wait for other pipelines'
branding:
icon: pause
color: purple
inputs:
step-name: # id of input
description: 'Step Name'
Expand Down

1 comment on commit 647f9ab

@marcohutzsch1234
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baski-accenture please publish at github actions marketplace

Please sign in to comment.