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
ce55495
commit 16f07e9
Showing
1 changed file
with
14 additions
and
21 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 |
---|---|---|
|
@@ -49,30 +49,23 @@ jobs: | |
- name: Verify gh-pages Directory Contents | ||
run: ls -R ${{ github.workspace }}/gh-pages | ||
|
||
# Step 5: Clone or Ensure gh-pages Branch Exists and Update Submodule | ||
- name: Dist - Update Submodule | ||
# Step 5: Ensure a Clean gh-pages Directory and Update Submodule | ||
- name: Dist - Prepare gh-pages Directory | ||
run: | | ||
# Define the gh-pages path | ||
GHPAGES_PATH="${{ github.workspace }}/gh-pages" | ||
# Check if the gh-pages directory exists and is a Git repository | ||
if [ -d "$GHPAGES_PATH/.git" ]; then | ||
echo "gh-pages directory already exists and is a Git repository; skipping clone." | ||
cd "$GHPAGES_PATH" | ||
git pull origin gh-pages --rebase || true # Sync with remote, ignore errors if rebase fails | ||
else | ||
# If the directory exists but is not a Git repo, clear it | ||
# Remove gh-pages directory if it exists to ensure a clean slate | ||
if [ -d "$GHPAGES_PATH" ]; then | ||
rm -rf "$GHPAGES_PATH/*" | ||
else | ||
mkdir -p "$GHPAGES_PATH" | ||
echo "Removing existing gh-pages directory..." | ||
rm -rf "$GHPAGES_PATH" | ||
fi | ||
# Clone the gh-pages branch if it exists, or initialize it | ||
if git ls-remote --exit-code --heads https://github.com/${{ github.repository_owner }}/GCWeb.git gh-pages; then | ||
git clone --depth 1 https://github.com/${{ github.repository_owner }}/GCWeb.git --branch gh-pages "$GHPAGES_PATH" | ||
else | ||
# Initialize an empty gh-pages branch | ||
# Create an empty gh-pages branch if it doesn't exist | ||
git clone --depth 1 https://github.com/${{ github.repository_owner }}/GCWeb.git "$GHPAGES_PATH" | ||
cd "$GHPAGES_PATH" | ||
git checkout --orphan gh-pages | ||
|
@@ -82,19 +75,18 @@ jobs: | |
git push origin gh-pages | ||
cd .. | ||
fi | ||
fi | ||
# Move into the gh-pages directory and update the submodule | ||
cd "$GHPAGES_PATH" | ||
git submodule update --init --recursive | ||
# Set Git user identity for commits | ||
# Set Git user identity for commits in this environment | ||
git config user.name "GitHub Actions" | ||
git config user.email "[email protected]" | ||
# If the submodule doesn’t exist, add it | ||
if [ ! -d "GCWeb" ]; then | ||
git submodule add -b master https://github.com/ServiceCanada/wet-boew-demos.git GCWeb | ||
git submodule add -b master https://github.com/ServiceCanada/wet-boew-demos.git GCWeb | ||
fi | ||
# Fetch and reset submodule to the latest commit on the desired branch | ||
|
@@ -104,12 +96,12 @@ jobs: | |
# Try to reset to 'master' or fallback to 'gh-pages' | ||
if git rev-parse --verify origin/master > /dev/null 2>&1; then | ||
git reset --hard origin/master | ||
git reset --hard origin/master | ||
elif git rev-parse --verify origin/gh-pages > /dev/null 2>&1; then | ||
git reset --hard origin/gh-pages | ||
git reset --hard origin/gh-pages | ||
else | ||
echo "Neither 'master' nor 'gh-pages' branches found in the submodule repository." | ||
exit 1 | ||
echo "Neither 'master' nor 'gh-pages' branches found in the submodule repository." | ||
exit 1 | ||
fi | ||
cd .. | ||
|
@@ -119,6 +111,7 @@ jobs: | |
git pull --rebase origin gh-pages || true # Sync with remote, ignore rebase errors | ||
# Step 6: Force Push to gh-pages Branch with Authentication | ||
- name: Configure Remote with GitHub Token | ||
run: | | ||
|