Skip to content

Commit 5c8aa11

Browse files
plangerxai
andcommitted
Add workflows for publishing via GH pages
This change adds a Github workflow that builds the website and publishes the build result to branch `gh-pages` for every commit on `master`. In addition, it deploys a preview to https://github.com/eclipse-theia/theia-website-previews. Effectively, this is the first step of changing the hosting of the Theia website from Netlify to Github pages. For more information see https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/3874 This change applies the same technique as used in https://github.com/eclipse-langium/langium-website Co-authored-by: Olaf Lessenich <[email protected]>
1 parent 52b5cfd commit 5c8aa11

File tree

4 files changed

+139
-0
lines changed

4 files changed

+139
-0
lines changed

.github/workflows/preview.yml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Deploy PR previews
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- closed
10+
11+
concurrency: preview-${{ github.head_ref }}
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
jobs:
18+
build-preview:
19+
if: github.event_name == 'pull_request_target' && github.event.action != 'closed'
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Use Node.js 14.x
23+
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 #v3
24+
with:
25+
node-version: '14.x'
26+
registry-url: 'https://registry.npmjs.org'
27+
- name: Checkout
28+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4
29+
with:
30+
ref: ${{ github.event.pull_request.head.sha }}
31+
- name: Build website
32+
run: |
33+
npm install
34+
PATH_PREFIX="pr-previews/${{ github.event.number }}" npm run build -- --prefix-paths
35+
- name: Upload artifact
36+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 #v4
37+
with:
38+
name: "site"
39+
path: ./public
40+
41+
deploy-preview:
42+
needs: build-preview
43+
runs-on: ubuntu-latest
44+
permissions:
45+
pull-requests: write
46+
environment:
47+
name: pull-request-preview
48+
url: ${{ steps.deployment.outputs.deployment-url }}
49+
steps:
50+
# checkout required for pr-preview-action to succeed,
51+
# while the content will not be used
52+
- name: Checkout
53+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4
54+
- name: Download the preview page
55+
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 #v4
56+
with:
57+
name: "site"
58+
path: ./public
59+
- uses: rossjrw/pr-preview-action@f31d5aa7b364955ea86228b9dcd346dc3f29c408 #v1
60+
id: deployment
61+
with:
62+
source-dir: ./public
63+
preview-branch: previews
64+
umbrella-dir: pr-previews
65+
deploy-repository: eclipse-theia/theia-website-previews
66+
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
67+
action: auto
68+
69+
# remove the preview page when the PR got closed
70+
remove-preview:
71+
if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
72+
runs-on: ubuntu-latest
73+
permissions:
74+
pull-requests: write
75+
steps:
76+
# checkout required for pr-preview-action to succeed,
77+
# while the content will not be used
78+
- name: Checkout
79+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4
80+
- uses: rossjrw/pr-preview-action@f31d5aa7b364955ea86228b9dcd346dc3f29c408 #v1
81+
id: deployment
82+
with:
83+
preview-branch: previews
84+
umbrella-dir: pr-previews
85+
deploy-repository: eclipse-theia/theia-website-previews
86+
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
87+
action: auto

.github/workflows/publish.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Deploy Website
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
workflow_dispatch:
7+
8+
# Allow only one concurrent deployment
9+
# Do not cancel in progress as we want production deployments to complete.
10+
concurrency:
11+
group: "publish"
12+
cancel-in-progress: false
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout website sources
19+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4
20+
- name: Use Node.js 14.x
21+
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 #v3
22+
with:
23+
node-version: 14.x
24+
registry-url: 'https://registry.npmjs.org'
25+
- name: Configure Pages
26+
id: pages
27+
uses: actions/configure-pages@1f0c5cde4bc74cd7e1254d0cb4de8d49e9068c7d #v4
28+
- name: Build website
29+
run: |
30+
npm install
31+
npm run build
32+
- name: Upload artifact
33+
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa #v3
34+
with:
35+
path: ./public
36+
37+
publish:
38+
environment:
39+
name: github-pages
40+
url: ${{ steps.deployment.outputs.page_url }}
41+
runs-on: ubuntu-latest
42+
needs: build
43+
steps:
44+
- name: Deploy to GitHub Pages
45+
id: deployment
46+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e #v4

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ npm run serve
2828
## CI
2929

3030
The website is automatically built at and deployed to Netlify.
31+
A preview of each PR is deployed to Netlify.
32+
33+
In addition, every commit on `master` is built and published to branch `gh-pages`, which will soon replace the deployment of Netlify.
34+
A preview of every pull request is published at [eclipse-theia/theia-website-previews](https://github.com/eclipse-theia/theia-website-previews).
35+
For more information, see [`publish.yml`](.github/workflows/publish.yml) and [`preview.yml`](.github/workflows/preview.yml).
3136

3237
## License
3338

gatsby-config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
pathPrefix: process.env.PATH_PREFIX,
23
siteMetadata: {
34
title: 'Theia - Cloud and Desktop IDE Platform',
45
description: "Theia is an open-source cloud &nbsp; desktop IDE framework implemented in TypeScript."

0 commit comments

Comments
 (0)