Skip to content

Commit 5aeb649

Browse files
committedAug 8, 2024
revert to cloning defang and samples into cwd
github actions prevents cloning a repo outside of the current working directory: actions/checkout#197
1 parent baf821d commit 5aeb649

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed
 

‎.github/workflows/deploy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ jobs:
4444
uses: actions/checkout@v3
4545
with:
4646
repository: DefangLabs/defang
47-
path: ../defang
47+
path: defang
4848
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.version || 'main' }}
4949

5050
- name: Checkout DefangLabs/samples
5151
uses: actions/checkout@v3
5252
with:
5353
repository: DefangLabs/samples
54-
path: ../samples
54+
path: samples
5555
ref: main
5656

5757
- name: Set up Go

‎.github/workflows/test-deploy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ jobs:
2525
uses: actions/checkout@v3
2626
with:
2727
repository: DefangLabs/defang
28-
path: ../defang
28+
path: defang
2929
ref: main
3030

3131
- name: Checkout DefangLabs/samples
3232
uses: actions/checkout@v3
3333
with:
3434
repository: DefangLabs/samples
35-
path: ../samples
35+
path: samples
3636
ref: main
3737

3838
- name: Set up Go

‎scripts/prebuild.sh

+21-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22

33
set -e
44

5-
cd ../defang/src/cmd/gendocs && go run main.go ../../../../defang-docs/docs/cli
6-
cd -
5+
CWD=$(pwd)
6+
CLI_DOCS_PATH=$(readlink -f docs/cli)
7+
8+
# In CI (github actions), the defang and samples repositories must be cloned
9+
# into the working directory of the `defang-docs` repository.
10+
# In local development, however, the defang and samples repositories are cloned
11+
# into the parent directory of the `defang-docs` repository.
12+
if [ -d "../defang" ]; then
13+
DEFANG_PATH=$(readlink -f ../defang)
14+
else
15+
DEFANG_PATH=$(readlink -f ./defang)
16+
fi
17+
if [ -d "../samples" ]; then
18+
SAMPLES_PATH=$(readlink -f ../samples)
19+
else
20+
SAMPLES_PATH=$(readlink -f ./samples)
21+
fi
22+
23+
cd "$DEFANG_PATH/src/cmd/gendocs" && go run main.go "$CLI_DOCS_PATH"
24+
cd "$CWD"
725
node scripts/prep-cli-docs.js
8-
node scripts/prep-samples.js
26+
node scripts/prep-samples.js "$SAMPLES_PATH/samples"

‎scripts/prep-cli-docs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ fs.readdirSync(directoryPath).forEach(file => {
4747

4848
fs.writeFileSync(filePath, fileContent);
4949
}
50-
});
50+
});

‎scripts/prep-samples.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fs = require('fs');
22
const path = require('path');
33
const YAML = require('yaml');
44

5-
const samplesDir = path.join(__dirname, '..', '..', 'samples', 'samples');
5+
const samplesDir = process.argv[2];
66

77
// categories are directories in the current directory (i.e. we're running in samples/ and we might have a samples/ruby/ directory)
88
const directories = fs.readdirSync(samplesDir).filter(file => fs.statSync(path.join(samplesDir, file)).isDirectory());

0 commit comments

Comments
 (0)
Failed to load comments.