This repository was archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated README, action name, add branding
- Loading branch information
1 parent
606ded2
commit 647f9ab
Showing
2 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
647f9ab
There was a problem hiding this comment.
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