Skip to content

Commit

Permalink
In case of multimodule setup, the gh-pages deployment job finishing l…
Browse files Browse the repository at this point in the history
…ater, is removing the contents of the gh-pages branch deployed by the gh-pages deployment job finishing earlier. To overcome this problem, using the `clean-exclude` property to exclude the removal of certain folder.
  • Loading branch information
faisalazam committed Jun 21, 2023
1 parent 6c750c3 commit 1e71f8e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/parent-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: push
env:
JAVA_VERSION: 20
UPLOADED_ARTIFACTS_DIR: 'gh-pages'
SITE_DIR: 'gh-pages/staging'
STAGING_DIR: 'gh-pages/staging'

jobs:
setup-env:
Expand Down Expand Up @@ -63,15 +63,19 @@ jobs:
with:
name: ${{ env.UPLOADED_ARTIFACTS_DIR }}
path: ${{ env.UPLOADED_ARTIFACTS_DIR }}
- name: 'Log folder'
- name: 'Copy the `README.md` file to `${{ env.STAGING_DIR }}` folder'
run: cp README.md ${{ env.STAGING_DIR }}
- name: 'Copy the `LICENSE` file to `${{ env.STAGING_DIR }}` folder'
run: cp LICENSE ${{ env.STAGING_DIR }}
- name: 'Log ${{ env.UPLOADED_ARTIFACTS_DIR }} folder'
run: ls -lart ${{ env.UPLOADED_ARTIFACTS_DIR }}
- name: 'Copy the `README.md` file to `${{ env.SITE_DIR }}` folder'
run: cp README.md ${{ env.SITE_DIR }}
- name: 'Copy the `LICENSE` file to `${{ env.SITE_DIR }}` folder'
run: cp LICENSE ${{ env.SITE_DIR }}
- name: 'Log ${{ env.STAGING_DIR }} folder'
run: ls -lart ${{ env.STAGING_DIR }}
- name: 'Deploy to GitHub Pages'
if: ${{ github.ref == 'refs/heads/master' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ env.UPLOADED_ARTIFACTS_DIR }}
CLEAN: true # Automatically remove deleted files from the deploy branch
# to push the contents of the deployment folder into a specific directory on the deployment branch
target-folder: ${{ env.STAGING_DIR }}
clean-exclude: INDIVIDUAL_MODULES
18 changes: 10 additions & 8 deletions .github/workflows/putting-all-together.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,21 @@ jobs:
mkdir -p ${{ env.SITE_DIR }}/jacoco-merged/jacoco-resources/badges
cp ${{ env.UPLOADED_ARTIFACTS_DIR }}/svgs/* ${{ env.SITE_DIR }}/jacoco-merged/jacoco-resources/badges
rm -rf ${{ env.UPLOADED_ARTIFACTS_DIR }}/svgs
- name: 'Create `INDIVIDUAL_MODULES` folder and place it in `${{ env.SITE_DIR }}` with site contents'
#Adding a new `INDIVIDUAL_MODULES` folder inside `site` folder to contain individual modules deployed site.
#It's just to avoid the overwriting of the contents deployed by the `parent pom` in the `gh-pages` branch.
run: |
mkdir -p INDIVIDUAL_MODULES/${{ env.MODULE_DIR }}
mv ${{ env.SITE_DIR }}/* INDIVIDUAL_MODULES/${{ env.MODULE_DIR }}
mv INDIVIDUAL_MODULES ${{ env.SITE_DIR }}
# - name: 'Create `INDIVIDUAL_MODULES` folder and place it in `${{ env.SITE_DIR }}` with site contents'
# #Adding a new `INDIVIDUAL_MODULES` folder inside `site` folder to contain individual modules deployed site.
# #It's just to avoid the overwriting of the contents deployed by the `parent pom` in the `gh-pages` branch.
# run: |
# mkdir -p INDIVIDUAL_MODULES/${{ env.MODULE_DIR }}
# mv ${{ env.SITE_DIR }}/* INDIVIDUAL_MODULES/${{ env.MODULE_DIR }}
# mv INDIVIDUAL_MODULES ${{ env.SITE_DIR }}
- name: 'Deploy to GitHub Pages'
if: ${{ github.ref == 'refs/heads/master' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ env.SITE_DIR }}
CLEAN: true # Automatically remove deleted files from the deploy branch
# to push the contents of the deployment folder into a specific directory on the deployment branch
target-folder: ${{ env.SITE_DIR }}/INDIVIDUAL_MODULES/${{ env.MODULE_DIR }}
clean-exclude: staging

deploy-to-gh-packages:
needs:
Expand Down

0 comments on commit 1e71f8e

Please sign in to comment.