Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/build-docusaurus-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,43 @@ jobs:
echo "//npm.pkg.github.com/:_authToken=${{ secrets.CI_GITHUB_TOKEN }}" >> ~/.npmrc

- name: Check that build works
id: build
run: |
# use templates from the current branch
cd pipelines/Docusaurus/docs
make

- name: Detect package-lock change
id: store
if: steps.build.outcome == 'success'
run: |
files=$(git diff "origin/${{ github.event.repository.default_branch }}" --name-only | paste -s -d,)
# Check if package-lock.json is changed
if [[ "$files" =~ "package-lock.json" ]]; then
echo "modules=yes" >> "${GITHUB_ENV}"
fi
shell: bash

# only update node_modules in the container if there's a change
- name: Zip node_modules
id: zip
run: |
if [ ${{ env.modules == 'yes' }} ]; then
mv pipelines/Docusaurus/docs/site-config/node_modules .
else
mv /node_modules .
fi
tar zcvf node_modules.gz node_modules/
shell: sh

- name: Upload node_modules
uses: actions/upload-artifact@v4
with:
name: node_modules.gz
path: node_modules.gz
if-no-files-found: error


parse-inputs:
needs: [checks]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -115,6 +147,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Download modules
uses: actions/download-artifact@v4
with:
name: node_modules.gz
path: pipelines/Docusaurus/
continue-on-error: false

- name: Unzip modules
run: |
cd pipelines/Docusaurus/
tar xzvf node_modules.gz
rm -rf node_modules.gz

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down
3 changes: 3 additions & 0 deletions pipelines/Docusaurus/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ RUN apk add --no-cache \

RUN mkdir /templates
COPY ./templates /templates
COPY ./node_modules /node_modules

EXPOSE 3000

WORKDIR /docs
6 changes: 4 additions & 2 deletions pipelines/Docusaurus/docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ default: test

test:
cp -r ../templates/* site-config/
./site-config/build.sh --skip-templates
./site-config/build.sh --skip-templates --skip-build

cd site-config && npm ci && npm run build

clean:
cd site-config; rm -rf docs version* package* docusaurus* node_modules build* tsconfig.json src
cd site-config; rm -rf docs version* package* docusaurus* node_modules build* run* tsconfig.json src
2 changes: 1 addition & 1 deletion pipelines/Docusaurus/templates/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function copy_templates() {
# if running on CI/local job, move the templates to the site-config
if [[ "${skip_templates}" != "yes" ]]; then
cp -r /templates/* ${site_dir}/
ln -s /node_modules ${site_dir}/
fi
}

Expand Down Expand Up @@ -104,6 +105,5 @@ fi

if [ "${skip_build}" != "yes" ]; then
cd "${site_dir}"
npm ci
npm run build
fi
Loading