From 05fb47aa3e3879212731ef156e79a807e9c63b7c Mon Sep 17 00:00:00 2001 From: SBsudo Date: Tue, 17 Dec 2024 09:21:55 -0500 Subject: [PATCH] test 921 --- .github/workflows/demo-deploy.yml | 55 ++++++++++++++++++------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/.github/workflows/demo-deploy.yml b/.github/workflows/demo-deploy.yml index ab7ab4ab1..de1ce1a49 100644 --- a/.github/workflows/demo-deploy.yml +++ b/.github/workflows/demo-deploy.yml @@ -27,16 +27,7 @@ jobs: - name: Install Bower run: npm install -g bower - # Step 3A: Cache Node.js dependencies - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: node_modules - key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - # Step 3B: Install dependencies and build demo files + # Step 3: Install dependencies and build demo files - name: Install dependencies run: npm install --legacy-peer-deps @@ -58,20 +49,20 @@ jobs: run: | GHPAGES_PATH="${{ github.workspace }}/gh-pages" if [ -d "$GHPAGES_PATH" ]; then - rm -rf "$GHPAGES_PATH" + rm -rf "$GHPAGES_PATH" fi git clone https://github.com/${{ github.repository_owner }}/GCWeb.git "$GHPAGES_PATH" cd "$GHPAGES_PATH" if git rev-parse --verify origin/gh-pages; then - git checkout gh-pages - git pull origin gh-pages + git checkout gh-pages + git pull origin gh-pages else - git checkout --orphan gh-pages - git rm -rf . - touch .nojekyll - git add .nojekyll - git commit -m "Initialize gh-pages branch" - git push --force origin gh-pages + git checkout --orphan gh-pages + git rm -rf . + touch .nojekyll + git add .nojekyll + git commit -m "Initialize gh-pages branch" + git push --force origin gh-pages fi # Step 5: Copy built files into the already cloned gh-pages folder @@ -79,18 +70,38 @@ jobs: run: | GHPAGES_PATH="${{ github.workspace }}/gh-pages" if [ -d "./~sites" ]; then - rsync -av ./~sites/ "$GHPAGES_PATH/" + rsync -av ./~sites/ "$GHPAGES_PATH/" fi if [ -d "./dist" ]; then - rsync -av ./dist/ "$GHPAGES_PATH/" + rsync -av ./dist/ "$GHPAGES_PATH/" fi - # Step 6: Commit and push + # Step 6: Commit and Push to gh-pages - name: Commit and Push to gh-pages run: | cd ${{ github.workspace }}/gh-pages + + # Configure Git for this environment git config user.name "GitHub Actions" git config user.email "actions@github.com" + + # Ensure remote uses the GitHub token + git remote set-url origin https://${{ secrets.GH_PAT }}@github.com/${{ github.repository_owner }}/GCWeb.git + + # Check out or initialize gh-pages + if git rev-parse --verify origin/gh-pages; then + git checkout gh-pages + git pull origin gh-pages + else + git checkout --orphan gh-pages + git rm -rf . + touch .nojekyll + git add .nojekyll + git commit -m "Initialize gh-pages branch" + git push --force origin gh-pages + fi + + # Stage and commit all changes to gh-pages git add . git commit -m "Update gh-pages with new demo files" --allow-empty git pull --rebase origin gh-pages || true