Skip to content

Commit 4bc4433

Browse files
authored
Merge pull request #728 from zihanKuang/add-academy-contribute-guide
Docs: Add Advanced Contributor Guide for Academy
2 parents c165ad7 + d1f1d36 commit 4bc4433

File tree

1 file changed

+128
-0
lines changed
  • content/en/cloud/academy/advanced-contribution-guide

1 file changed

+128
-0
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
title: "Advanced Contributor Guide"
3+
weight: 5
4+
description: >
5+
An advanced guide to the Layer5 Academy architecture, multi-repository workflow, and development best practices for contributors.
6+
categories: [Academy]
7+
---
8+
9+
This guide walks you through the Layer5 Academy platform's multi-repository architecture. You will learn the role of each core component and master the practical workflows for theme development, local testing, and end-to-end validation with Layer5 Cloud.
10+
11+
## The Multi-Repository Model
12+
13+
The [Layer5 Academy platform](https://cloud.layer5.io/academy) is built on a "separation of concerns" architecture. Instead of a single monolithic repository, we use a multi-repository model where content, style, and build configurations are managed independently. This approach keeps the system modular, simplifies maintenance, and allows teams to work on different parts of the platform concurrently.
14+
15+
At a high level, the `academy-theme` provides the visual style for content from repositories like `academy-example`, and the `academy-build` repository acts as the central factory, assembling everything into the final website.
16+
17+
## Core Repositories
18+
19+
The Layer5 Academy platform is composed of several core repositories.
20+
21+
### [academy-theme](https://github.com/layer5io/academy-theme)
22+
23+
This repository is the "skin" for the entire Academy. It controls the website's design, including all the layouts, colors, and fonts.
24+
25+
Content repositories automatically import this theme as a Go Module. As a content creator, you do not need to fork or clone this repository; your academy will use these styles by default.
26+
27+
> Currently, we only support customizing shortcodes in your content repository, not full theme customization.
28+
29+
### [academy-example](https://github.com/layer5io/academy-example)
30+
31+
This is the "starter kit" for anyone new to creating Academy content. It provides a pre-configured site that new organizations can fork to get started quickly.
32+
33+
> [Learn How](../creating-your-learning-path/) to create your own learning path
34+
35+
This content repository doesn't build the final website itself. Instead, it uses an automated workflow to act as a "gatekeeper" for new content. When you create a new GitHub Release, it triggers the following process:
36+
37+
1. **Sanity Check**: It first runs a local build to ensure the new content has no fundamental errors that would break the site.
38+
39+
2. **Publishing Notification**: If the check passes, it calls a reusable action from the `academy-build` repository. This action securely sends a request to the Layer5 Cloud API, using your configured `ACADEMY_ORG_ID` and `ACADEMY_TOKEN` secrets.
40+
41+
{{< alert type="info" title="Publishing Trigger" >}}
42+
This request effectively says: "A new version of content is ready for this organization. Please update it." This workflow does not build the final site; it only validates the content and notifies the build system.
43+
{{< /alert >}}
44+
45+
### [academy-build](https://github.com/layer5io/academy-build)
46+
47+
**This is the central hub of the entire system.** It contains the main Hugo configuration for the production build and uses Go Modules to manage the versions of all content modules and the `academy-theme`.
48+
49+
When its workflow is triggered, an automated process acts like a master assembly line:
50+
51+
1. **Collects Parts**: It begins by gathering all the necessary components—`academy-theme` and all the course content from the various content repositories.
52+
53+
2. **Assembles the Website**: Next, it combines everything. It applies the theme's design to all the course content, building a single, complete website.
54+
55+
3. **Deploys Online**: Finally, it takes the newly built website and automatically pushes it to the cloud platform, making the updates live for everyone to see.
56+
57+
## Developer Workflows
58+
59+
### How to Develop and Preview Locally
60+
61+
Use this workflow for rapid local development and iteration. If you're only changing Markdown files and want a fast preview loop, run these commands within a content repository (such as `layer5-academy`):
62+
63+
{{< alert type="info" title="layer5-academy as an Example" >}}
64+
We'll use [layer5-academy](https://github.com/layer5io/layer5-academy) for these examples because it hosts all official Layer5 learning paths. It serves as a feature-complete reference, allowing you to see how a complex, real-world content repository is structured.
65+
{{< /alert >}}
66+
67+
1. `go mod tidy`: Cleans up and verifies Go module dependencies.
68+
2. `make setup`: Installs necessary tools and modules.
69+
3. `make site`: Starts the local Hugo development server.
70+
71+
You can then view your content by navigating to `http://localhost:1313/academy`.
72+
73+
### How to Develop the Academy Theme
74+
75+
If you need to modify the `academy-theme` and see its effect on real content, you'll use the `go mod replace` directive:
76+
77+
1. **Modify the Theme**: Make your code changes in your local clone of the `academy-theme` repository.
78+
2. **Redirect the Dependency**: In the `go.mod` file of the content repository you're using for previewing (e.g., `layer5-academy`), add a `replace` directive to point Hugo to your local theme directory:
79+
```go
80+
replace github.com/layer5io/academy-theme => ../academy-theme
81+
```
82+
3. **Apply Changes and Relaunch**: Run `go mod tidy` to apply the `replace` directive you just added. Then, restart the server with `make site`. The local server will now use your local theme code, allowing you to see your changes instantly.
83+
84+
### How to Use End-to-End Testing with Layer5 Cloud
85+
86+
Use this workflow for end-to-end testing that mirrors the production environment. This is the ultimate way to verify your changes work correctly within the Layer5 Cloud UI before they go live:
87+
88+
All steps in this section should be performed from the root of your local `academy-build` repository.
89+
90+
1. **Prepare Local Dependencies**: If you're testing local changes from other repositories (like a theme or content module), edit the `go.mod` file in `academy-build` to point to your local versions using a replace directive:
91+
```go
92+
replace github.com/layer5io/academy-theme => ../academy-theme
93+
replace github.com/layer5io/layer5-academy => ../layer5-academy
94+
```
95+
96+
2. **Build Locally**: Run the command to build the entire Academy site. This fetches all remote content modules and the theme:
97+
```bash
98+
make academy-dev
99+
```
100+
101+
3. **Sync with Cloud**: After the build completes, run the following command to sync the generated static files with the Layer5 Cloud staging environment:
102+
```bash
103+
make sync-with-cloud
104+
```
105+
106+
4. **Preview on Staging**: Your changes will be available on the [staging environment](https://staging-cloud.layer5.io/) within approximately 10 minutes.
107+
108+
{{< alert type="warning" title="Local vs. Cloud Discrepancies" >}}
109+
The local preview (`make site`) is excellent for rapid development, but it is **not** a 100% accurate representation of the final product. The Cloud UI acts as a wrapper around the Academy content, which can introduce subtle differences. These are often caused by CSS class conflicts or variations in JavaScript execution within the larger application.
110+
111+
**Always verify your changes in the staging environment before considering them complete.**
112+
{{< /alert >}}
113+
114+
### When to Use a Holistic Build Test
115+
116+
If you need a faster way to check the final output without syncing to the cloud, you can run a production-like build locally from the `academy-build` repo:
117+
118+
```bash
119+
make academy-prod
120+
```
121+
122+
This command generates the final static files in the `public/` directory. You can inspect the generated HTML and JSON files here to diagnose build-time issues before deploying.
123+
124+
### Best Practices
125+
126+
1. **Keep Dependencies Clean**: After testing with local replace directives in your `go.mod` file, always remember to remove them and run `go mod tidy` before committing your changes. This prevents accidental check-ins of local paths.
127+
2. **Test Incrementally**: Start with local development for rapid iteration, then progress to holistic builds, and finally test in the staging environment.
128+
3. **Version Control**: Always commit your changes to version control before testing in staging to ensure you can track and revert changes if needed.

0 commit comments

Comments
 (0)