Skip to content

Commit 038ab43

Browse files
Copilotyuhattor
andcommitted
Add GitHub Codespaces and PR preview workflow
Co-authored-by: yuhattor <15963767+yuhattor@users.noreply.github.com>
1 parent d702922 commit 038ab43

File tree

6 files changed

+219
-0
lines changed

6 files changed

+219
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "Hugo (InnerSource Commons Website)",
3+
"image": "hugomods/hugo:base-0.133.1",
4+
"features": {
5+
"ghcr.io/devcontainers/features/git:1": {}
6+
},
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"bungcip.better-toml",
11+
"davidanson.vscode-markdownlint",
12+
"esbenp.prettier-vscode",
13+
"ms-vscode.live-server",
14+
"tamasfe.even-better-toml"
15+
],
16+
"settings": {
17+
"editor.formatOnSave": true,
18+
"editor.defaultFormatter": "esbenp.prettier-vscode"
19+
}
20+
}
21+
},
22+
"forwardPorts": [1313],
23+
"remoteUser": "root",
24+
"postCreateCommand": "echo 'Hugo server ready to run! Use the Run and Debug view to start the server.'"
25+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Description
2+
<!-- Describe the changes you are making -->
3+
4+
## Website Preview
5+
<!-- A preview of this PR will be automatically generated. -->
6+
<!-- It may take a few minutes after creation/update to appear. -->
7+
<!-- You'll see the preview link in a comment below. -->
8+
9+
## Checklist
10+
- [ ] I have tested these changes locally
11+
- [ ] I have updated documentation if necessary
12+
- [ ] I have verified the preview looks as expected (when the preview comment appears)

.github/workflows/pr-preview.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: PR Preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
build-preview:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Setup Hugo
14+
uses: peaceiris/actions-hugo@v2
15+
with:
16+
hugo-version: '0.133.1'
17+
extended: true
18+
19+
- name: Copy the missing files from /content/en for publishing each language site
20+
run: |
21+
for i in fr ja pt-br; do
22+
rsync -rv --ignore-existing content/en/ content/$i/ --log-file=content/.gitignore;
23+
sed -i "s/^.\{37\} /$i\//g" content/.gitignore;
24+
sed -i '/total size\|file list/d' content/.gitignore;
25+
done
26+
27+
- name: Build
28+
run: hugo --minify
29+
30+
- name: Deploy PR Preview
31+
uses: rossjrw/pr-preview-action@v1
32+
with:
33+
source-dir: ./public/
34+
preview-branch: gh-pages
35+
umbrella-dir: pr-preview
36+
action: auto
37+
38+
- name: Find Comment
39+
uses: peter-evans/find-comment@v1
40+
id: fc
41+
with:
42+
issue-number: ${{ github.event.pull_request.number }}
43+
comment-author: 'github-actions[bot]'
44+
body-includes: "Preview this PR"
45+
46+
- name: Create or Update Comment
47+
uses: peter-evans/create-or-update-comment@v1
48+
with:
49+
comment-id: ${{ steps.fc.outputs.comment-id }}
50+
issue-number: ${{ github.event.pull_request.number }}
51+
body: |
52+
### :rocket: Preview this PR
53+
54+
You can view a preview of the website changes at:
55+
https://innersourcecommons.github.io/innersourcecommons.org/pr-preview/pr-${{ github.event.pull_request.number }}/
56+
57+
This preview will be updated automatically as you make changes to the PR.
58+
59+
_Note: The preview may take a few moments to deploy after changes are pushed._
60+
edit-mode: replace

.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Hugo Server",
6+
"type": "node",
7+
"request": "launch",
8+
"runtimeExecutable": "hugo",
9+
"runtimeArgs": [
10+
"server",
11+
"--appendPort=false",
12+
"--baseURL=/",
13+
"-D"
14+
],
15+
"console": "integratedTerminal"
16+
}
17+
]
18+
}

CODESPACES.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Using GitHub Codespaces for Website Preview
2+
3+
This guide will help you use GitHub Codespaces to preview changes to the InnerSource Commons website without needing to set up a local development environment.
4+
5+
## What is GitHub Codespaces?
6+
7+
GitHub Codespaces is a cloud-based development environment that allows you to work on projects directly from your browser. It's perfect for contributors who don't want to set up a local development environment.
8+
9+
## Getting Started with Codespaces
10+
11+
### Step 1: Navigate to the Repository
12+
13+
Go to the [InnerSource Commons website repository](https://github.com/InnerSourceCommons/innersourcecommons.org) on GitHub.
14+
15+
### Step 2: Create a New Codespace
16+
17+
1. Click the green "Code" button near the top right of the repository page
18+
2. Select the "Codespaces" tab
19+
3. Click "Create codespace on master"
20+
21+
![Create a Codespace](https://github.com/user-attachments/assets/e6bf365c-a119-4609-bbae-20efcb8cba18)
22+
23+
### Step 3: Wait for the Codespace to Load
24+
25+
The Codespace will take a minute or two to set up. You'll see a loading screen while it prepares the environment.
26+
27+
### Step 4: Run the Hugo Server
28+
29+
Once the Codespace is loaded:
30+
31+
1. Click the "Run and Debug" icon in the left sidebar (it looks like a play button with a bug)
32+
2. At the top of the Run and Debug panel, click on the dropdown and select "Hugo Server"
33+
3. Click the green play button to start the Hugo server
34+
35+
### Step 5: View the Website Preview
36+
37+
When the Hugo server starts:
38+
39+
1. A notification will appear in the bottom right corner saying "Your application running on port 1313 is available"
40+
2. Click "Open in Browser" to view the website in a new tab
41+
42+
### Step 6: Make and Preview Changes
43+
44+
1. Navigate to the `content` folder to find the files you want to edit
45+
2. Make your changes to the files
46+
3. Save your changes (Ctrl+S or Cmd+S)
47+
4. The website preview will automatically update with your changes
48+
49+
## Working with Branches and Pull Requests
50+
51+
### Creating a New Branch
52+
53+
1. Click the branch name in the bottom left corner of the Codespace
54+
2. Select "Create new branch..." from the dropdown menu
55+
3. Enter a name for your branch and press Enter
56+
57+
### Committing Your Changes
58+
59+
1. Click the "Source Control" icon in the left sidebar (it looks like a branch)
60+
2. Review your changes
61+
3. Enter a commit message in the text box
62+
4. Click the checkmark icon to commit your changes
63+
64+
### Creating a Pull Request
65+
66+
1. After committing your changes, click the "..." menu in the Source Control panel
67+
2. Select "Push" to push your changes to GitHub
68+
3. When prompted, click "Create Pull Request"
69+
4. Fill out the pull request form and click "Create"
70+
71+
## Troubleshooting
72+
73+
If you encounter any issues:
74+
75+
- **Hugo server not starting**: Try restarting the Codespace by clicking on the menu in the bottom left corner and selecting "Codespaces: Stop Current Codespace" and then restarting it.
76+
- **Changes not showing**: Make sure you've saved your files and that the Hugo server is running.
77+
- **Port not forwarding**: Click the "Ports" tab at the bottom of the Codespace and make sure port 1313 is forwarded.
78+
79+
## Getting Help
80+
81+
If you're stuck, you can:
82+
83+
1. Check the [Hugo documentation](https://gohugo.io/documentation/)
84+
2. Ask for help in the InnerSource Commons community channels
85+
3. Create an issue on the GitHub repository

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ In case the widget adds cookies to the website please update the Privacy Policy
1818

1919
## Installation and local run
2020

21+
### Using GitHub Codespaces (Recommended for Non-Technical Contributors)
22+
23+
GitHub Codespaces provides an easy way to work on the website without installing anything on your local machine:
24+
25+
1. Navigate to the repository on GitHub
26+
2. Click the green "Code" button
27+
3. Select the "Codespaces" tab
28+
4. Click "Create codespace on master"
29+
5. Wait for the codespace to load (this may take a minute)
30+
6. Once loaded, click the "Run and Debug" icon in the sidebar (or press F5)
31+
7. Select "Hugo Server" from the dropdown menu and click the play button
32+
8. When prompted, click "Open in Browser" to view the website
33+
34+
The website will be displayed in a new browser tab, and any changes you make will automatically update in real-time.
35+
36+
For a more detailed guide with screenshots, please see our [Codespaces documentation](CODESPACES.md).
37+
38+
### Local Installation
39+
2140
If you want to test the page before commit you can run the site locally.
2241
you need to have `git` and [hugo][] installed. Please follow the official installation instructions.
2342

0 commit comments

Comments
 (0)