Skip to content

Commit

Permalink
Add option to retry yarn-install
Browse files Browse the repository at this point in the history
  • Loading branch information
Augusto Moura committed Dec 19, 2023
1 parent b8cea43 commit 176ec52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions yarn-install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The list of arguments, that are used in GH Action:
| `path` | string | | . | Relative path under $GITHUB\_WORKSPACE where to run `yarn install` command |
| `checkout-token` | string | | | Repository checkout access token `GITHUB_TOKEN`. Required for self-hosted runners |
| `npm-gar-token` | string | | | Repository npm Artifact Registry access token `NPM_GAR_TOKEN`. Required when using self-hosted runners with npm in GAR (Google Artifact Registry, the npm registry works as a proxy-cache, downloading and storing the public npm packages) |
| `maxAttempts` | string | | 1 | How many times to retry installing. This is specially useful if the building of packages might fail because of network connections |

### Outputs

Expand Down
11 changes: 10 additions & 1 deletion yarn-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
npm-gar-token:
description: Repository npm Artifact Registry access token `NPM_GAR_TOKEN`. Required when using self-hosted runners with npm in GAR (Google Artifact Registry, the npm registry works as a proxy-cache, downloading and storing the public npm packages)
required: false
maxAttempts:
description: How many times to retry installing. This is specially useful if the building of packages might fail because of network connections
default: "1"
required: false
outputs:
cache-hit:
description: "Indicates an exact match was found for `node_modules` || boolean"
Expand Down Expand Up @@ -119,5 +123,10 @@ runs:
working-directory: ${{ inputs.path }}
env:
NPM_TOKEN: ${{ inputs.npm-token || env.NPM_TOKEN }}
MAX_ATTEMPTS: ${{ inputs.max-attempts }}
run: |
yarn install --frozen-lockfile --non-interactive
for i in {1..$MAX_ATTEMPTS}; do
printf "Trying to install #%s...\n" "$i"
yarn install --frozen-lockfile --non-interactive && break
sleep 10 # 10s wait time
done

0 comments on commit 176ec52

Please sign in to comment.