Skip to content

Commit 842305a

Browse files
feat(workflow): add configurable working directory
1 parent 1695481 commit 842305a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.github/workflows/rust-build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
description: 'Cargo profile to use for building (debug, release)'
1212
default: 'release'
1313
type: string
14+
working-directory:
15+
description: 'The directory to run jobs from'
16+
default: '.'
17+
type: string
1418
run-audit:
1519
description: 'Run cargo-audit for security vulnerabilities'
1620
default: true
@@ -46,6 +50,7 @@ env:
4650
jobs:
4751
build:
4852
runs-on: ubuntu-latest
53+
working-directory: ${{ inputs.working-directory }}
4954
steps:
5055
- name: Checkout repository
5156
uses: actions/checkout@v4
@@ -100,6 +105,7 @@ jobs:
100105
needs: build
101106
if: ${{ inputs.publish-crates-io && needs.build.result == 'success' }}
102107
runs-on: ubuntu-latest
108+
working-directory: ${{ inputs.working-directory }}
103109
steps:
104110
- name: Checkout repository
105111
uses: actions/checkout@v4

rust-build/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ A reusable GitHub Actions workflow for building, linting, testing, and auditing
99
- Check formatting with `cargo fmt`
1010
- Run security audits with `cargo audit`
1111
- Cache dependencies for faster builds
12+
- Set a working directory for monorepos
1213
- Upload build artifacts
1314
- Publish to crates.io
1415

@@ -25,6 +26,7 @@ jobs:
2526
with:
2627
rust-version: 'stable'
2728
build-target: 'release'
29+
working-directory: './my-crate'
2830
run-audit: true
2931
enable-cache: true
3032
upload-artifact: true
@@ -40,6 +42,7 @@ jobs:
4042
| ------------------- | ------------------------------------------------------------ | --------- | -------- |
4143
| `rust-version` | Rust version to use | `stable` | No |
4244
| `build-target` | Cargo profile to use for building (`debug`, `release`, etc.) | `release` | No |
45+
| `working-directory` | The directory to run jobs from | `.` | No |
4346
| `run-audit` | Run `cargo audit` for security vulnerabilities | `true` | No |
4447
| `enable-cache` | Enable caching of dependencies | `true` | No |
4548
| `upload-artifact` | Upload a build artifact after building | `false` | No |
@@ -63,6 +66,16 @@ jobs:
6366
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/rust-build.yml@main
6467
```
6568

69+
### Specify a Working Directory
70+
71+
```yaml
72+
jobs:
73+
build-and-test:
74+
uses: iExecBlockchainComputing/github-actions-workflows/.github/workflows/rust-build.yml@main
75+
with:
76+
working-directory: './my-crate'
77+
```
78+
6679
### Disable Security Audit
6780

6881
```yaml

0 commit comments

Comments
 (0)