You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fix Robots.txt to be automatically generated for Production
generation of robots.txt.
Validate on staging site and fix staging yaml code to work correctly with GitHub pages
Update GitHub Action replacing PeaceIris actions with vanilla GitHub actions; align with Hugo's documented deployment process
* Update Readme
Add section on Staging
---------
Signed-off-by: Bill Stumbo <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+99-17
Original file line number
Diff line number
Diff line change
@@ -86,35 +86,117 @@ reflection of the bibliographic material related to Medley and Interlisp.
86
86
87
87
Building the website is driven by a GitHub workflow.
88
88
89
-
The workflow is trigger by one of two events, a `push` to main, representing updates
89
+
The workflow is triggered by one of two events, a `push` to main, representing updates
90
90
to the Interlisp.org website or a scheduled execution of the workflow. The
91
91
workflow is scheduled to run on a regular basis to ensure the bibliography remains
92
92
consistent with the online Zotero catalog.
93
93
94
-
The workflow consists of two jobs. The first job, `check`, uses Zotero's REST
95
-
interface to query for the latest version of the group bibliography. The call
96
-
made is a `GET` call to `https://api.zotero.org/groups/2914042/items`. This call
94
+
The GitHub Action workflow can also be initiated from the Action panel within
95
+
the Interlisp.github.io repository. This option allows manual execution when
96
+
necessary.
97
+
98
+
The workflow consists of three jobs. The first job, `check`, uses Zotero's REST
99
+
interface to query for the latest version of the group bibliography. A `GET` call
100
+
is made to `https://api.zotero.org/groups/2914042/items`. It
97
101
returns a collection of metadata and information describing the current state of
98
102
items within the catalog. We are interested in a specific header, `Last-Modified-Version`.
99
103
The value returned with this header is incremented every time the Zotero Interlisp
100
-
catalog is updated. The value returned is used as a cache-key for a cached
101
-
version of the json file of the bibliography we create. The first job completes
102
-
by providing the current Zotero version and whether the cache needs to be updated.
104
+
catalog is updated. We use the value returned as a cache-key for the bibliography.
105
+
If the cache-key matches one in the current GitHub Action cache we use the saved
106
+
bibliography information and save the overhead of building it.
103
107
104
-
The second job, `deploy`, starts by determining if a deploy needs to occur. If
105
-
the workflow was initiated by a `push` a deploy will always be done. However,
106
-
if the workflow was started by a scheduled execution, if the Zotero bibliography
107
-
cache is consistent with the online Zotero catalog, the deploy is skipped.
108
+
The second job, `build`, starts by determining if a build and deploy need to occur.
109
+
If the workflow was initiated by a `push` a deploy will always be done. However,
110
+
if the workflow was started by a scheduled execution and the Zotero bibliography
111
+
cache is consistent with the online Zotero catalog, the build and deploy are skipped.
108
112
109
-
A deploy starts by checking out the `Interlisp.github.io` repository. Then,
110
-
if the cache is valid, the contents are copied into the `data` file within the
113
+
A build starts by checking out the `Interlisp.github.io` repository. Then,
114
+
if the Zotereo cache is valid, its contents are copied into the `data` file within the
111
115
repository directory structure. If the cache is invalid, the `update_bibliography.sh`
112
-
shell script is run to download a new copy of the bibliography as a `json` file.
116
+
shell script runs and downloads a new copy of the bibliography as a `json` file.
113
117
Once downloaded the script does some additional processing to complete the
114
118
formatting of the file.
115
119
116
-
Once this work is completed, Hugo is setup and the website is deployed.
120
+
After this work is completed, Hugo is setup and run to build the website. We use
121
+
Hugo extended to build our site. The version of Hugo currently being used is
122
+
defined by the environment variable, `HUGO_VERSION`.
123
+
124
+
We run Hugo with two flags:
125
+
126
+
-`-e $HUGO_ENVIRONMENT` to specify whether we are building a production or staging site. If the website is being build to deploy to Interlisp.org,it should be built with `HUGO_ENVIRONMENT` set to production. Deployment to any other site should set the environment flag to staging.
127
+
-`--cleanDestinationDir` clears the destination directory, `./public` on each build. This will ensure we do not have any unneeded artifacts in our deployment.
128
+
129
+
The last part of the build activity is to save the created artifact, the information
130
+
in the `./public` directory. We use the GitHub composition action `upload-pages-artifact`
131
+
for this. It packages the contents of the directory and stores it in the appropriate
132
+
format for deployment to GitHub pages.
133
+
134
+
The last job in the tool chain is `deploy`. This job simply takes the output
135
+
of the build step and formally deploys it to GitHub pages using the GitHub `deploy-pages`
136
+
action.
137
+
138
+
### Deploying a Staging Site
139
+
140
+
Successfully deploying a Staging Site requires you to configure your GitHub
141
+
repository to enable GitHub Pages. The following steps will accomplish this task:
142
+
143
+
1. Clone the Interlisp.github.io repository into your GitHub site
144
+
2. In GitHub go to the cloned repository, in my case https://github.com/stumbo/InterlispDraft.github.io and select Settings
145
+
3. Under Settings, find Pages and select it
146
+
4. Under **Build and deployment** set Source to Deploy *GitHub Actions*
147
+
148
+
Once the repository is cloned and GitHub Pages has been setup, you can deploy a
149
+
staging site to validate changes prior to creating a Pull Request to merge your
150
+
changes back into the main site.
151
+
152
+
When creating a staging site we want to do a couple things to ensure we do not
153
+
interfere with the production site, first we want to disable Google Analytics
154
+
and secondly we want to ensure the site is not crawled and indexed.
155
+
156
+
#### Setup Your Repository
157
+
158
+
A best practice for the updating your clone of the repository is to create a branch
159
+
and make the following required changes on the branch you created.
160
+
161
+
The appropriate settings for this are all enabled by setting the `HUGO_ENVIRONMENT`
162
+
variable in `.github/workflows/gh-pages.yaml` to *staging*.
163
+
164
+
You also need to set `baseURL` to match the GitHub site you are deploying to
165
+
in the `config/staging/hugo.yaml` file. The file currently looks like:
# Insert Staging Environment onto every page to make clear
174
+
# this is not the production site
175
+
title: 'Staging Environment'
176
+
```
177
+
178
+
Make sure the `baseURL` reflects the complete path of your repository. Failure
179
+
to do this will either cause the deployment to fail or URLs within your built
180
+
site may be incorrectly set. Resulting in 404s or expected resources not found.
181
+
182
+
With these changes the cloned repository is ready to be deployed to a staging site.
183
+
184
+
Commit the changes you made and push the new branch to your cloned repository.
185
+
At this point, create a Pull Request to merge the changes you made into your
186
+
repository's main branch. Complete the operation by merging the pull request.
187
+
188
+
Once the merge occurs, the GitHub Actions should fire off and your site will be
189
+
built and deployed.
190
+
191
+
Once you have successfully completed this operation and your staging site is
192
+
deployed and operational you can experiment with adding new content or
193
+
functionality to the Interlisp site.
194
+
195
+
#### Develop a Feature
117
196
197
+
To develop new pages or functionality, create a new branch for your work. once
198
+
you have completed development and testing on your staging site, you can create
199
+
a PR to merge the content into the Interlisp site.
118
200
119
201
### Running Hugo and Docsy Locally
120
202
@@ -233,7 +315,7 @@ that have components specific to `Interlisp.github.io` are as follows:
233
315
- `documentation`- contains the pdf files referenced in the document section of the home page
234
316
- `favicons`- contains `favicon.png` a small icon that browsers can use when referencing the website
235
317
- `Resources`- contains the current `Interlisp-D` logo, used on the home page, and another instance of `favicon.png`
236
-
- `CNAME` - a oneline text file that provides support for using a [custom domain](https://gohugo.io/hosting-and-deployment/hosting-on-github/#use-a-custom-domain)
318
+
- `CNAME`- a one line text file that provides support for using a [custom domain](https://gohugo.io/hosting-and-deployment/hosting-on-github/#use-a-custom-domain)
237
319
238
320
## Search
239
321
@@ -256,7 +338,7 @@ layout as being `search`.
256
338
257
339
### Updating Search
258
340
259
-
Modfying the websites that are searched requires updating the Google Custom
341
+
Modifying the websites that are searched requires updating the Google Custom
260
342
Search engine settings. This is done via logging into Google's Programmable Search
0 commit comments