Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ A collection of reusable GitHub Actions and Workflows for Shopware extensions an
|--------|-------------|------|
| [setup-extension](setup-extension/) | Checkouts Shopware and extension, installs dependencies | [README](setup-extension/README.md) |
| [shopware-version](shopware-version/) | Gets the Shopware version that matches the current branch | [README](shopware-version/README.md) |
| [npm-ci-retry](npm-ci-retry/) | Runs npm install commands with retry handling | [README](npm-ci-retry/README.md) |
| [versions](versions/) | Gets version information for current and LTS major versions | [README](versions/README.md) |

### Workflow Orchestration
Expand Down
12 changes: 12 additions & 0 deletions npm-ci-retry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# npm ci retry

Runs `npm ci` or another install command with three attempts and npm retry settings.

## Usage

```yaml
- uses: shopware/github-actions/npm-ci-retry@main
with:
working-directory: path/to/package
command: npm ci
```
38 changes: 38 additions & 0 deletions npm-ci-retry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "npm ci with retry"
description: >-
Runs `npm ci` (or an equivalent install command) with retries and offline
preference so transient registry resets (ECONNRESET) don't fail the job.
Cache `~/.npm` in a preceding step to make the retries reuse tarballs offline.

inputs:
working-directory:
description: "Directory to run the install in."
required: false
default: "."
command:
description: "Install command to run (e.g. `npm ci` or `composer run npm:storefront ci`)."
required: false
default: "npm ci"

runs:
using: composite
steps:
- shell: bash
working-directory: ${{ inputs.working-directory }}
env:
npm_config_fetch_retries: "5"
npm_config_fetch_retry_mintimeout: "20000"
npm_config_fetch_retry_maxtimeout: "120000"
npm_config_prefer_offline: "true"
run: |
for attempt in 1 2 3; do
if ${{ inputs.command }}; then
break
fi
if [ "${attempt}" -eq 3 ]; then
echo "::error::'${{ inputs.command }}' failed after ${attempt} attempts"
exit 1
fi
echo "::warning::'${{ inputs.command }}' failed (attempt ${attempt}/3); retrying in $((attempt * 15))s"
sleep "$((attempt * 15))"
done