Skip to content

Commit

Permalink
Add docs + publish
Browse files Browse the repository at this point in the history
  • Loading branch information
milespetrov committed Sep 3, 2024
1 parent 7e6cdfa commit 56f2c1a
Showing 1 changed file with 49 additions and 11 deletions.
60 changes: 49 additions & 11 deletions .github/workflows/demo-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ jobs:
node-version: '22.5.1'
cache: 'npm'

- name: Set up Git
run: |
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
- name: Build or delete the demo
run: |
BRANCH_OR_TAG_NAME=${GITHUB_REF#refs/heads/}
BRANCH_OR_TAG_NAME=${BRANCH_OR_TAG_NAME#refs/tags/}
git config --global user.email "[email protected]"
git config --global user.name "Miles Petrov"
git fetch --all
# Check if demo-page branch exists and create it if necessary
Expand All @@ -57,13 +59,40 @@ jobs:
git checkout -b temp-$BRANCH_OR_TAG_NAME
# Create a subfolder and checkout demo-page's content
mkdir demo-folder
mkdir -p demo-folder/$BRANCH_OR_TAG_NAME/docs
git --work-tree=demo-folder checkout demo-page -- .
# Modify and commit changes
npm ci
npm run build
npm run ts-docs:generate
npm run vite-docs:generate
- name: Publish to NPM
if: github.repository == 'ramp4-pcar4/ramp4-pcar4' && startsWith(github.ref, 'refs/tags/v')
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
npm version --allow-same-version --no-git-tag-version $TAG_VERSION
fi
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Build or delete the demo
run: |
BRANCH_OR_TAG_NAME=${GITHUB_REF#refs/heads/}
BRANCH_OR_TAG_NAME=${BRANCH_OR_TAG_NAME#refs/tags/}
# Remove the existing demo if it exists
rm -rf demo-folder/$BRANCH_OR_TAG_NAME || true
# Move the built files and docs into the demo-folder
mv dist demo-folder/$BRANCH_OR_TAG_NAME
mv vite-docs demo-folder/$BRANCH_OR_TAG_NAME/docs
mv ts-docs demo-folder/$BRANCH_OR_TAG_NAME/docs/api-tech-docs
rm -rf node_modules
git add demo-folder
Expand All @@ -75,17 +104,26 @@ jobs:
git checkout temp-$BRANCH_OR_TAG_NAME -- demo-folder
mv demo-folder/* .
rmdir demo-folder
git add .
- name: Update docsite version references
uses: jacobtomlinson/gha-find-replace@v3
with:
find: '{{ramp-version}}'
replace: ${{ github.ref_name }}
include: '$BRANCH_OR_TAG_NAME/docs/**'
regex: false

- name: Consolidate docsite files
run: |
git add .
git commit -m "Applied changes from demo-folder to demo-page"
git commit -m "Applied changes from demo-folder to demo-page"
# Squash the commit history into a single commit
git reset --soft $(git rev-list --max-parents=0 HEAD)
git commit -m "Applied changes from demo-folder to demo-page"
git push -f origin demo-page
# Squash the commit history into a single commit
git reset --soft $(git rev-list --max-parents=0 HEAD)
git commit -m "Applied changes from demo-folder to demo-page"
git push -f origin demo-page
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down

0 comments on commit 56f2c1a

Please sign in to comment.