Skip to content

Commit

Permalink
revert to cloning defang and samples into cwd
Browse files Browse the repository at this point in the history
github actions prevents cloning a repo outside of the current working
directory: actions/checkout#197
  • Loading branch information
jordanstephens committed Aug 8, 2024
1 parent baf821d commit b4ad0c1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 21 additions & 3 deletions scripts/prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion scripts/prep-cli-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ fs.readdirSync(directoryPath).forEach(file => {

fs.writeFileSync(filePath, fileContent);
}
});
});
2 changes: 1 addition & 1 deletion scripts/prep-samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit b4ad0c1

Please sign in to comment.