updated demo-deployment #4
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 and initialize submodules | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive # This initializes and updates submodules automatically | |
# 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 | |
- name: Build Demo Files (GCWeb) | |
if: contains(github.ref, 'gcweb') | |
run: | | |
grunt demo --branch=${{ github.ref_name }} # Use branch name in Grunt command | |
docker-compose up -d # Assuming docker-compose is needed for build | |
- name: Build Demo Files (WET-BOEW) | |
if: contains(github.ref, 'wet-boew') | |
run: grunt dist | |
# Step 4: Copy built files to a temporary directory for deployment | |
- name: Copy Built Files | |
run: | | |
mkdir -p demo_files | |
if [ -d "./~sites" ]; then cp -R ./~sites/* demo_files/; fi | |
if [ -d "./dist" ]; then cp -R ./dist/* demo_files/; fi | |
# Step 5: Deploy to gh-pages branch, including submodule update | |
- name: Deploy Demo | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GH_PAT }} | |
publish_dir: ./demo_files | |
publish_branch: gh-pages | |
user_name: 'GitHub Actions' | |
user_email: '[email protected]' | |
# Step 6: Add and commit submodule changes | |
- name: Update Submodules and .gitmodules | |
run: | | |
git submodule add -b ${{ github.ref_name }} https://github.com/ServiceCanada/wet-boew-demos.git ${{ github.ref_name }} | |
git add .gitmodules ${{ github.ref_name }} | |
git commit -m "Added submodule for ${{ github.ref_name }}" | |
git push origin gh-pages |