forked from ramp4-pcar4/ramp4-pcar4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e6cdfa
commit 56f2c1a
Showing
1 changed file
with
49 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|