Prompt
Ensure CI/CD workflows maintain reliability by following these practices:
-
Use explicit script paths - Always use explicit paths when invoking scripts (e.g.,
./build.ps1for PowerShell or./build.shfor bash) rather than relying on implicit path resolution. This ensures the runner can locate and execute scripts regardless of the current working directory. - Verify script existence - Confirm that all referenced script files and directories exist in the repository before merging workflow changes:
```yaml
Before merging, verify that these paths exist:
-
name: Build packages (Windows) run: ./scripts/build-packages.ps1
-
name: Build packages (Unix) run: ./scripts/build-packages.sh ```
-
- Set execute permissions - Include a step to set execute permissions for shell scripts on Unix systems:
```yaml
-
name: Set permissions run: chmod +x ./build.sh
-
name: Build run: ./build.sh ```
-
- Handle secrets securely - Add conditional guards when using repository secrets to accommodate PRs from forks where secrets aren’t available:
```yaml
- name: Run tests requiring API keys if: $ run: npm test env: API_KEY: $ ```
These practices will prevent common CI/CD failures and improve workflow reliability across different environments and contributor scenarios.