Skip to content

Commit 3ba33aa

Browse files
committed
Build: adding workflow to build GCWeb using gh-pages
1 parent 21b3b9f commit 3ba33aa

File tree

4 files changed

+208
-2
lines changed

4 files changed

+208
-2
lines changed

.github/workflows/gh-pages.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Build for gh-pages
2+
3+
on:
4+
push:
5+
branches: dev
6+
7+
jobs:
8+
build-test:
9+
runs-on: ubuntu-latest
10+
11+
environment: dev
12+
13+
strategy:
14+
matrix:
15+
node-version: [22.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Cache node modules
21+
id: cache-npm
22+
uses: actions/cache@v4
23+
env:
24+
cache-name: cache-node-modules
25+
with:
26+
path: ~/.npm
27+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
28+
restore-keys: |
29+
${{ runner.os }}-build-${{ env.cache-name }}-
30+
${{ runner.os }}-build-
31+
${{ runner.os }}-
32+
33+
- name: Use Node.js ${{ matrix.node-version }}
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: ${{ matrix.node-version }}
37+
- run: npm i -g bower grunt-cli
38+
39+
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
40+
uses: actions/setup-node@v4
41+
name: Install dependencies
42+
run: npm install
43+
44+
- name: Copy the missing _sprite_share.scss file - related to GCWeb#1737 about wet-boew#cc340a6 commit
45+
run: |
46+
curl https://gist.githubusercontent.com/duboisp/d69787b300eb1f4d40f937508e10d013/raw/86e7a0b15ad6a695754599e9793e986b460bf514/_sprites_share.scss >> _sprites_share.scss
47+
mv _sprites_share.scss node_modules/wet-boew/src/plugins/share/sprites/_sprites_share.scss
48+
49+
- name: Checkout wet-boew latest build
50+
run: |
51+
git clone --depth 1 https://github.com/wet-boew/wet-boew-cdn.git --branch v4.0-dist ~wet-boew-cdn
52+
mkdir -p node_modules/wet-boew/dist/wet-boew
53+
rm -rf node_modules/wet-boew/dist/wet-boew/*
54+
mv ~wet-boew-cdn/* node_modules/wet-boew/dist/wet-boew
55+
56+
- name: Build GCWeb
57+
run: grunt build-gh-pages
58+
59+
- name: Git config
60+
run: |
61+
git config --global user.name "Service Canada bot"
62+
git config --global user.email "bot@servicecanada.gc.ca"
63+
64+
# Overwrite all layout and includes and remove dist from .gitignore
65+
- name: Update GCWeb Jekyll theme files
66+
run: |
67+
cp -R ~jekyll-dist/_includes/* _includes/
68+
cp -R ~jekyll-dist/_layouts/* _layouts/
69+
sed -i '/^dist\/$/s/^/#/' .gitignore
70+
git add .
71+
git commit -m "CD ${{ github.run_id }}: Update GCWeb jekyll theme files" --allow-empty
72+
73+
- name: Deploy to gh-pages branch
74+
run: |
75+
git add .
76+
git commit -m "Deploy to gh-pages" --allow-empty
77+
78+
- name: Jekyll theme - Deploy
79+
uses: ad-m/github-push-action@v0.8.0
80+
with:
81+
branch: gh-pages
82+
force: true
83+
github_token: ${{ secrets.my_token }}
84+

Gruntfile.coffee

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ module.exports = (grunt) ->
6363
]
6464
)
6565

66+
@registerTask(
67+
"build-gh-pages"
68+
"Build a gh-pages working copy without dependencies check"
69+
[
70+
"jekyll-theme"
71+
"jekyll-theme-runGHPages"
72+
"core-dist-DEBUG"
73+
"site-contents"
74+
]
75+
)
76+
6677
@registerTask(
6778
"demo"
6879
"Build a demo ready version of the site"
@@ -154,6 +165,15 @@ module.exports = (grunt) ->
154165
]
155166
)
156167

168+
@registerTask(
169+
"jekyll-theme-runGHPages"
170+
"DEBUG - Jekyll theme but with the run local variant"
171+
[
172+
"usebanner:jekyllRunGHPages"
173+
"copy:jekyllRunLocal"
174+
]
175+
)
176+
157177
@registerTask(
158178
"jekyll-theme-runDemo"
159179
"DEBUG - Jekyll theme but with the run demo variant"
@@ -673,6 +693,11 @@ module.exports = (grunt) ->
673693
banner: """{%- assign setting-resourcesBasePathTheme = "/wet-boew-demos/""" + grunt.option('branch') + """/<%= distFolder %>/GCWeb" -%}{%- assign setting-resourcesBasePathWetboew = "/wet-boew-demos/""" + grunt.option('branch') + """/<%= distFolder %>/wet-boew" -%}{%- assign setting-siteBasePath = "/wet-boew-demos/""" + grunt.option('branch') + """/" -%}"""
674694
position: "bottom"
675695
src: "<%= jekyllDist %>/_includes/settings.liquid"
696+
jekyllRunGHPages:
697+
options:
698+
banner: """{%- assign setting-resourcesBasePathTheme = "/GCWeb/<%= distFolder %>/GCWeb" -%}{%- assign setting-resourcesBasePathWetboew = "/GCWeb/<%= distFolder %>/wet-boew" -%}{%- assign setting-siteBasePath = "/GCWeb/" -%}"""
699+
position: "bottom"
700+
src: "<%= jekyllDist %>/_includes/settings.liquid"
676701
jekyllRunUnminified:
677702
options:
678703
banner: """{%- assign setting-minifiedSuffix = "" -%}"""

docs/developing-en.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ grunt debug
4545
docker run -it --rm -v "$PWD":/usr/src/app -p "4000:4000" --env JEKYLL_OPTIONS='--config _config.yml,_localJekyll.yml' jekyll-with-env-options
4646
```
4747

48-
### alternative with docker-compose
48+
### Alternative with docker-compose
4949

5050
This version leverage the remote theme wet-boew/gcweb-jekyll. This equivalent if you run with gh-pages through your own GCWeb repository.
5151

@@ -56,7 +56,7 @@ docker-compose up
5656

5757
First time run: `docker-compose up --build`
5858

59-
## Run the continuos integration and deployment script locally
59+
## Run the continuous integration and deployment script locally
6060

6161
Install ACT - [https://github.com/nektos/act](https://github.com/nektos/act)
6262

@@ -124,6 +124,53 @@ Where:
124124

125125
Note: A manual update is required if you have specified a version for your jekyll remote theme in your `config.yml` file.
126126

127+
## Develop using Github Pages
128+
129+
### 1. Create Personal Access Token (PAT)
130+
131+
Once your Github Pages are set up, you'll have to generate a personal access token in order for the Github Actions workflow to work. Here are the steps:
132+
133+
1. Go to this URL: [https://github.com/settings/tokens](https://github.com/settings/tokens)
134+
2. Select "Generate new token".
135+
3. Select "Generate new token (classic)".
136+
4. **Note**: "GCWeb dev for Github Pages"
137+
5. Select the `repo` checkbox.
138+
6. Select "Generate new token".
139+
7. Copy the token.
140+
141+
### 2. Create your environment
142+
143+
You'll now have to add the token you created to the dev environment:
144+
145+
1. In your GCWeb fork, go to the Settings tab.
146+
2. In the Settings page, go to the "Enviromnents" tab.
147+
3. **Name**: dev
148+
4. Select "Configure environment".
149+
5. Under "Environment secrets", select "Add environment secret":
150+
151+
* **Name**: my_secret
152+
* **Value**: [Paste the token you copied in step 1.7]
153+
154+
### 3. Setup Github Pages
155+
156+
To be able to view GCWeb through Github, you'll have to setup your repo to use Github pages. Here's how to do so:
157+
158+
1. In your GCWeb fork, go to the Settings tab.
159+
2. In the Settings page, go to the Pages tab.
160+
3. **Source**: deploy from a branch
161+
4. **Branch**: gh-pages | /(root) (if you don't have the `gh-pages` branch already, you'll have to create it)
162+
5. You are now set up to start developing.
163+
164+
### 4. Develop using the Github Pages workflow
165+
166+
You are now set up to start developing. Here's the process to do so:
167+
168+
1. Make your changes in your `dev` local branch.
169+
2. Run `git add .`
170+
3. Run `git commit "[Your commit message]"`. For ulterior changes, run `git commit --amend --no-edit`.
171+
4. Run `git push -f origin dev`.
172+
5. Repeat step 2 to 4 everytime you are ready to test your changes.
173+
127174
## Contribute to GCWeb
128175

129176
When you work on fixing or improving GCWeb, for example by troubleshooting a bug or creating a new feature, it could be interesting for all if you would contribute back to the project so that every implementation of GCWeb can benefit from your work. To do so, please read our [code of conduct](https://github.com/wet-boew/GCWeb/blob/master/CONTRIBUTING.md).

docs/developing-fr.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
}
99
---
1010

11+
<div lang="en">
1112
[Needs translation]
1213

1314
Install NodeJS
@@ -126,6 +127,55 @@ Where:
126127

127128
Note: A manual update is required if you have specified a version for your jekyll remote theme in your `config.yml` file.
128129

130+
## Develop using Github Pages
131+
132+
### 1. Create Personal Access Token (PAT)
133+
134+
Once your Github Pages are set up, you'll have to generate a personal access token in order for the Github Actions workflow to work. Here are the steps:
135+
136+
1. Go to this URL: [https://github.com/settings/tokens](https://github.com/settings/tokens)
137+
2. Select "Generate new token".
138+
3. Select "Generate new token (classic)".
139+
4. **Note**: "GCWeb dev for Github Pages"
140+
5. Select the `repo` checkbox.
141+
6. Select "Generate new token".
142+
7. Copy the token.
143+
144+
### 2. Create your environment
145+
146+
You'll now have to add the token you created to the dev environment:
147+
148+
1. In your GCWeb fork, go to the Settings tab.
149+
2. In the Settings page, go to the "Enviromnents" tab.
150+
3. **Name**: dev
151+
4. Select "Configure environment".
152+
5. Under "Environment secrets", select "Add environment secret":
153+
154+
* **Name**: my_secret
155+
* **Value**: [Paste the token you copied in step 1.7]
156+
157+
### 3. Setup Github Pages
158+
159+
To be able to view GCWeb through Github, you'll have to setup your repo to use Github pages. Here's how to do so:
160+
161+
1. In your GCWeb fork, go to the Settings tab.
162+
2. In the Settings page, go to the Pages tab.
163+
3. **Source**: deploy from a branch
164+
4. **Branch**: gh-pages | /(root) (if you don't have the `gh-pages` branch already, you'll have to create it)
165+
5. You are now set up to start developing.
166+
167+
### 4. Develop using the Github Pages workflow
168+
169+
You are now set up to start developing. Here's the process to do so:
170+
171+
1. Make your changes in your `dev` local branch.
172+
2. Run `git add .`
173+
3. Run `git commit "[Your commit message]"`. For ulterior changes, run `git commit --amend --no-edit`.
174+
4. Run `git push -f origin dev`.
175+
5. Repeat step 2 to 4 everytime you are ready to test your changes.
176+
177+
</div>
178+
129179
## Contribuer à GCWeb
130180

131181
Lorsque vous effectuez des correctifs ou améliorations à GCWeb, tels que la correction d'un bogue ou l'ajout d'une fonctionnalité, il pourrait être intéressant pour toutes et tous de contribuer au projet afin que tous les implémentations de GCWeb puissent en bénéficier. Pour ce faire, veuillez consulter les [lignes directrices de contribution de GCWeb](https://github.com/wet-boew/GCWeb/blob/master/CONTRIBUTING.md#comment-contribuer).

0 commit comments

Comments
 (0)