Skip to content

Commit 200cb4b

Browse files
authored
fix the GitHub action files that lead to conflicts (#78)
* readme * update readme to include instructions for updating * Isolate PR previews to prevent overwriting production site * Update pr-preview.yml * Isolate PR previews to prevent overwriting production site The previous pull request preview workflow deployed directly to the GitHub Pages environment, completely overwriting the existing site content. This meant that generating a PR preview would take down the live production site. This commit modifies the preview workflow to make it non-destructive: - The workflow now first checks out the `main` branch and builds the full production site into the `/public` directory. - It then checks out the pull request's head branch and builds the specific PR preview into a subdirectory (e.g., `/public/pr-123`). - The combined result is then deployed, ensuring that the production site and the PR preview can coexist. * fix(ci): Isolate PR previews to prevent overwriting production site The previous pull request preview workflow deployed directly to the GitHub Pages environment, completely overwriting the existing site content. This meant that generating a PR preview would take down the live production site. This commit modifies the preview workflow to make it non-destructive: - The workflow now first checks out the `main` branch and builds the full production site into the `/public` directory. - It then checks out the pull request's head branch and builds the specific PR preview into a subdirectory (e.g., `/public/pr-123`). - The combined result is then deployed, ensuring that the production site and the PR preview can coexist. This change prevents conflicts between the preview and production deployment pipelines. * update: add debug log * fix(ci): Correct Hugo build destination path The Hugo build was creating the 'public' directory inside the checkout subdirectories instead of the workspace root. This caused the artifact upload step to fail. This commit corrects the '--destination' flag for both Hugo build commands to use an absolute path, ensuring the build output is placed in the correct location.
1 parent e8380d4 commit 200cb4b

2 files changed

Lines changed: 96 additions & 13 deletions

File tree

.github/workflows/pr-preview.yml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,55 @@ jobs:
3838
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
3939
- name: Install Dart Sass Embedded
4040
run: sudo snap install dart-sass-embedded
41-
- name: Checkout
42-
uses: actions/checkout@v4
43-
with:
44-
submodules: recursive
4541
- name: Setup Pages
4642
id: pages
4743
uses: actions/configure-pages@v5
48-
- name: Install Node.js dependencies
44+
45+
# Build production site from base branch
46+
- name: Checkout base branch
47+
uses: actions/checkout@v4
48+
with:
49+
ref: ${{ github.base_ref }}
50+
path: base
51+
submodules: recursive
52+
- name: Install Node.js dependencies for base
53+
working-directory: base
54+
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
55+
- name: Build production site
56+
env:
57+
HUGO_ENVIRONMENT: production
58+
HUGO_ENV: production
59+
run: |
60+
hugo \
61+
--source base \
62+
--minify \
63+
--baseURL "${{ steps.pages.outputs.base_url }}/" \
64+
--destination "${{ github.workspace }}/public"
65+
66+
# Build PR preview
67+
- name: Checkout PR branch
68+
uses: actions/checkout@v4
69+
with:
70+
ref: ${{ github.event.pull_request.head.sha }}
71+
path: pr
72+
submodules: recursive
73+
- name: Install Node.js dependencies for PR
74+
working-directory: pr
4975
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
5076
- name: Set preview baseURL
5177
id: base_url
52-
run: echo "base_url=https://yqtian.com/${{ github.event.repository.name }}/pr-${{ github.event.number }}" >> $GITHUB_OUTPUT
53-
- name: Build with Hugo
78+
run: echo "base_url=${{ steps.pages.outputs.base_url }}/pr-${{ github.event.number }}" >> $GITHUB_OUTPUT
79+
- name: Build PR preview
5480
env:
55-
# For maximum backward compatibility with Hugo modules
5681
HUGO_ENVIRONMENT: production
5782
HUGO_ENV: production
5883
run: |
5984
hugo \
85+
--source pr \
6086
--minify \
6187
--baseURL "${{ steps.base_url.outputs.base_url }}/" \
62-
--destination "public/pr-${{ github.event.number }}"
88+
--destination "${{ github.workspace }}/public/pr-${{ github.event.number }}"
89+
6390
- name: Upload artifact
6491
uses: actions/upload-pages-artifact@v3
6592
with:
@@ -86,5 +113,5 @@ jobs:
86113
uses: peter-evans/create-or-update-comment@v4
87114
with:
88115
issue-number: ${{ github.event.pull_request.number }}
89-
body: |
116+
body: | # This is a multiline string, so newlines are preserved correctly.
90117
Preview deployed at: ${{ needs.build.outputs.preview_url }}

README.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,60 @@
1-
# acmsigsoft.github.io
2-
SIGSOFT Website
1+
# Website of The ACM Special Interest Group on Software Engineering (SIGSOFT)
2+
3+
4+
[![Deploy to Production](https://github.com/acmsigsoft/acmsigsoft.github.io/actions/workflows/production-deploy.yml/badge.svg)](https://github.com/acmsigsoft/acmsigsoft.github.io/actions/workflows/production-deploy.yml)
5+
6+
## Overview
7+
Welcome to the ACM SIGSOFT GitHub repository!
8+
9+
This repository contains the source code for the [ACM SIGSOFT website](https://www2.sigsoft.org).
10+
The website is built using [Hugo-Universal-Theme](https://github.com/devcows/hugo-universal-theme) and hosted on GitHub Pages.
11+
12+
13+
The website is maintained by the [ACM SIGSOFT Information Director](https://www2.sigsoft.org/contact/).
14+
If you have any questions or suggestions, please feel free to contact the Information Director.
15+
16+
## Contributing
17+
If you would like to contribute to the website, please fork the repository and submit a pull request.
18+
We welcome contributions from anyone who is interested in improving the website.
19+
20+
Most of the content on the website can be revised by modifying the Markdown files in the `content` directory.
21+
Images and other static files can be added to the `static` directory.
22+
Configuration of the website, including the top bar and index page, can be done in the `config.toml` file.
23+
24+
### Development
25+
To editing the information on the website, you may fork this website repository and edit the content files in the `content` directory.
26+
Alternatively, you can also edit the content files directly on GitHub using the web interface.
27+
The content files are written in Markdown, and you can use any text editor to edit them.
28+
The website uses [Hugo](https://gohugo.io/) as the static site generator, so you will need to install Hugo to build the website locally.
29+
You can find the documentation for Hugo [here](https://gohugo.io/documentation/).
30+
31+
32+
33+
### Testing
34+
To test the website locally, please clone this repository and run the following commands:
35+
36+
```bash
37+
# Clone the repository and its submodules
38+
# you may have to change the URL to your forked repository
39+
git clone --recurse-submodules git@github.com:acmsigsoft/acmsigsoft.github.io.git
40+
41+
# Install Hugo if you haven't already
42+
# See https://gohugo.io/installation/
43+
brew install hugo # For macOS users
44+
sudo snap install hugo # For linux users
45+
46+
# Navigate to the repository directory
47+
cd acmsigsoft.github.io
48+
49+
# Start the Hugo server
50+
hugo server
51+
```
52+
53+
Alternatively, to test the website on GitHub, please create a pull request and the GitHub Actions workflow will automatically build and deploy the website to a staging environment.
54+
You can then review the changes on the staging environment before asking for reviewing the pull request.
55+
56+
There are two GitHub Actions workflows defined in the `.github/workflows` directory:
57+
- `pr-preview.yml`: This workflow is triggered on pull requests and deploys the website to a temporary URL.
58+
- `production-deploy.yml`: This workflow is triggered on pushes to the main branch and deploys the website to the production URL.
59+
You can enable these workflows in your forked repository by going to the "Actions" tab and clicking on the "Enable workflow" button.
360

4-
[![Deploy Hugo site to Pages](https://github.com/acmsigsoft/acmsigsoft.github.io/actions/workflows/main.yml/badge.svg)](https://github.com/acmsigsoft/acmsigsoft.github.io/actions/workflows/main.yml)

0 commit comments

Comments
 (0)