forked from wet-boew/GCWeb
-
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
f9769d2
commit 05fb47a
Showing
1 changed file
with
33 additions
and
22 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 |
---|---|---|
|
@@ -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,39 +49,59 @@ 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 | ||
- name: Copy Built Files to gh-pages Root | ||
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 "[email protected]" | ||
# 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 | ||
|