Welcome to CorpX documentation! Our documentation serves as a vital resource for understanding our products, services, and processes. It ensures clarity, consistency, and accessibility for both internal teams and external users. We value your contributions to keeping our documentation robust and up-to-date.
Clear and comprehensive documentation is essential for several reasons:
- Accessibility: It provides easy access to information for all stakeholders, including developers, designers, and end-users.
- Consistency: It ensures consistency in communication, reducing confusion and errors.
- Onboarding: New team members can quickly familiarize themselves with our products and processes, accelerating their onboarding process.
- Troubleshooting: It serves as a reference point for troubleshooting common issues and resolving queries efficiently.
You are a new DevOps engineer at CorpX. You have been tasked with creating a GitHub Actions workflow to automate the deployment process of CorpX's internal knowledge base.
This knowledge base receives contributions on a daily basis through pull requests to this repository. The previous engineers have been releasing the changes manually at the end of each week. However, this is not good enough for CorpX. They want to publish changes as soon as they are merged to the main branch.
-
Launch your project workspace and open the terminal (Use the menu bar at the top: Terminal > New Terminal)
-
Run the web server and make sure the docs are rendered, with images and style properly:
$ npm run workspace:dev ... Starting up http-server, serving ./ http-server version: 14.1.1 http-server settings: CORS: disabled Cache: 3600 seconds Connection Timeout: 120 seconds Directory Listings: visible AutoIndex: visible Serve GZIP Files: false Serve Brotli Files: false Default File Extension: none Available on: http://127.0.0.1:8080 http://10.124.12.199:8080 Hit CTRL-C to stop the server Open: http://127.0.0.1:8080/_site/
-
If everything went well, you will see:
Open: http://127.0.0.1:8080/_site/
-
To open the site, you need to navigate to the "Ports" tab (right next to the terminal tab)
-
Under "Local Address" you should see a URL similar to this:
https://yotzaustpu.prod.udacity-student-workspaces.com/proxy/8080/
-
Click on the "Globe" icon to open the link directly in your browser or copy and paste the full link
- You should be able to see the knowledge base fully rendered and you should be able to navigate through all the links
Once the above is done, you can proceed to the next steps.
Create a new GitHub Actions workflow called deploy.yaml
. This workflow should at least:
- Trigger a workflow run when changes are pushed to the
main
branch and only themain
branch. All pushes to other branches should be ignored- Do no trigger a run when any of these files have been changed:
.gitignore
README.md
CONTRIBUTING.md
LICENSE
- Do no trigger a run when any of these files have been changed:
- Trigger a workflow run when for every
pull_request
created again themain
branch only. All pull requests created against other branches should be ignored - In case of an emergency, you'll want the option to trigger a force deployment. Your workflow should include that option
- Your workflow should have a maximum of 1 run at all times. If other runs are queued, the older runs should be canceled
- Your workflow should have at least 3 jobs:
test
build
deploy
- Your workflow should run fast, it should not take more than
2 minutes (120 seconds)
(on average) to run all the jobs - You must adopt the security best practices discussed in the course and outlined in the docs
For this job, you are required to:
- Checkout the repository
- Setup Node (version 18+)
- Install all the dependencies needed. Use the cache to speed up the process
- Run all the linters
- Run all the scripts in the folder
script/**
- You should define and use a repository variable named
URL_CHECKER_TIMEOUT
to configure thetimeout
value for thescript/url-checker.js
script- Use any reasonable value (in seconds)
The job should fail if any of its steps fail.
For this job, you are required to:
- Make sure that the
test
job ran and succeeded - Checkout the repository
- Setup pages using
actions/configure-pages@v4
- Setup Node (version 18+)
- Install all the dependencies needed. Use the cache to speed up the process
- Build the static pages
- In order for 11ty to build your site successfully, it requires an environment variable
PATH_PREFIX
to be set and to have the value of the name of your repository - The
PATH_PREFIX
should be of the following format:/repository name/
. Make sure that the repository name does not include the repository owner! Do not forget the/
at the start and end
- In order for 11ty to build your site successfully, it requires an environment variable
- Build your site by running:
npm run prod
- Upload all the content of the built
_site
as an artifact
The job should fail if any of its steps fail.
For this job, you are required to:
- Never deploy changes if any of the previous jobs (
test
,build
) fail - Deploy your site to GitHub pages
- Using the GitHub CLI, authenticate to GitHub with
GITHUB_TOKEN
and create an issue that reports the status of the deployment. The issue should have:- Title:
<date> - Deployment: <status>
- Make sure to replace
<date>
with today's date - Make sure to replace
<status>
with the outcome of the deployment (succeeded or failed)
- Make sure to replace
- Body:
URL: <url>
- Make sure to replace
<url>
with the link to the knowledge base
- Make sure to replace
- Title:
The job should fail if any of its steps fail.
Once you've successfully completed your project, you need to submit the following:
- The
deploy.yml
workflow file - The link to your repository
- The link to your published knowledge base website on GitHub pages
spruecss-eleventy-documentation-template/
├─ node_modules/
├─ dist/
├─ src/
│ ├─ _data/
│ ├─ _includes/
│ ├─ css/
│ ├─ filters/
│ ├─ font/
│ ├─ img/
│ ├─ js/
│ ├─ posts/
│ ├─ scss/
│ ├─ shortcodes/
│ ├─ transforms/
│ ├─ changelog.md
│ ├─ faq.md
│ ├─ index.md
├─ .eleventy.js
├─ package.json
├─ README.md
├─ ...
- _data: Some global data, like the name of your site and helpers like the active navigation element or current year.
- __includes: All of the layout and partial templates.
- css: The compiled CSS.
- filters: The additional filters that you can use.
- font: The custom fonts.
- img: The static image files.
- posts: The markdown contents.
- scss: The Sass files.
- shortcodes: The available shortcodes.
- transforms: The transformations.
-
To run all the linters in the project, you can use the following command:
$ npm run lint:all ...
-
To run the URL checker script, you can use the following command:
$ node url-checker.js -t <timeout> -p <path> Options: -t, --timeout <timeout> The timeout in seconds for each request. Default is 5000. -d, --directory <directory path> The path to the posts directory. Default is src/posts.
-
In order to fetch the repository name from a variable with the format:
owner/repository
, one way would be to usecut
:$ echo "owner/repository" | cut -d'/' -f2- repository
-
To build the site so that it's compatible with GitHub Pages, you can use the following commands:
$ PATH_PREFIX="<name of your repository>" $ npm run prod ...