diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index df772fc89..3051670a2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -44,14 +44,14 @@ jobs: uses: actions/checkout@v3 with: repository: DefangLabs/defang - path: ../defang + path: defang ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.version || 'main' }} - name: Checkout DefangLabs/samples uses: actions/checkout@v3 with: repository: DefangLabs/samples - path: ../samples + path: samples ref: main - name: Set up Go diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index f90969985..2e0803f2e 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -25,14 +25,14 @@ jobs: uses: actions/checkout@v3 with: repository: DefangLabs/defang - path: ../defang + path: defang ref: main - name: Checkout DefangLabs/samples uses: actions/checkout@v3 with: repository: DefangLabs/samples - path: ../samples + path: samples ref: main - name: Set up Go diff --git a/scripts/prebuild.sh b/scripts/prebuild.sh index ce049444a..1b34511bd 100755 --- a/scripts/prebuild.sh +++ b/scripts/prebuild.sh @@ -2,7 +2,25 @@ set -e -cd ../defang/src/cmd/gendocs && go run main.go ../../../../defang-docs/docs/cli -cd - -node scripts/prep-cli-docs.js +CWD=$(pwd) +CLI_DOCS_PATH=$(readlink -f docs/cli) + +# In CI (github actions), the defang and samples repositories must be cloned +# into the working directory of the `defang-docs` repository. +# In local development, however, the defang and samples repositories are cloned +# into the parent directory of the `defang-docs` repository. +if [ -d "../defang" ]; then + DEFANG_PATH=$(readlink -f ../defang) +else + DEFANG_PATH=$(readlink -f ./defang) +fi +if [ -d "../samples" ]; then + SAMPLES_PATH=$(readlink -f ../samples) +else + SAMPLES_PATH=$(readlink -f ./samples) +fi + +cd "$DEFANG_PATH/src/cmd/gendocs" && go run main.go "$CLI_DOCS_PATH" +cd "$CWD" +node scripts/prep-cli-docs.js "$SAMPLES_PATH/samples" node scripts/prep-samples.js diff --git a/scripts/prep-cli-docs.js b/scripts/prep-cli-docs.js index 323f15df2..9ec2fd591 100644 --- a/scripts/prep-cli-docs.js +++ b/scripts/prep-cli-docs.js @@ -47,4 +47,4 @@ fs.readdirSync(directoryPath).forEach(file => { fs.writeFileSync(filePath, fileContent); } -}); \ No newline at end of file +}); diff --git a/scripts/prep-samples.js b/scripts/prep-samples.js index 55b7b4027..4efe8ad04 100644 --- a/scripts/prep-samples.js +++ b/scripts/prep-samples.js @@ -2,7 +2,7 @@ const fs = require('fs'); const path = require('path'); const YAML = require('yaml'); -const samplesDir = path.join(__dirname, '..', '..', 'samples', 'samples'); +const samplesDir = process.argv[2]; // categories are directories in the current directory (i.e. we're running in samples/ and we might have a samples/ruby/ directory) const directories = fs.readdirSync(samplesDir).filter(file => fs.statSync(path.join(samplesDir, file)).isDirectory());