test 859 #49
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
name: Demo Deployment | |
on: | |
push: | |
branches: | |
- main | |
- 'gcweb-pr*' | |
- demo-deploy | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository (including submodules if needed) | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
# Step 2: Set up Node.js and Bower | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install Bower | |
run: npm install -g bower | |
# Step 3: Install dependencies and build demo files | |
- name: Install dependencies | |
run: npm install --legacy-peer-deps | |
# Optional: Debug - List project files before build | |
- name: Debug - List project files | |
run: ls -R | |
- name: Build Demo Files (GCWeb) | |
run: | | |
grunt demo --branch=${{ github.ref_name }} | |
docker compose up -d | |
docker compose down | |
- name: Build Demo Files (WET-BOEW) | |
run: grunt dist | |
# Step 4: Clone or set up gh-pages first | |
- name: Setup gh-pages | |
run: | | |
GHPAGES_PATH="${{ github.workspace }}/gh-pages" | |
if [ -d "$GHPAGES_PATH" ]; then | |
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 | |
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 | |
# 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/" | |
fi | |
if [ -d "./dist" ]; then | |
rsync -av ./dist/ "$GHPAGES_PATH/" | |
fi | |
# Step 6: Commit and push | |
- name: Commit and Push to gh-pages | |
run: | | |
cd ${{ github.workspace }}/gh-pages | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git add . | |
git commit -m "Update gh-pages with new demo files" --allow-empty | |
git pull --rebase origin gh-pages || true | |
git push origin gh-pages --force |