Skip to content

Commit dea8981

Browse files
author
Jason Young
committed
Add GitHub action to build and push the site when changed on master
1 parent 7c21d29 commit dea8981

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+110
-11876
lines changed

.github/workflows/site.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
name: Build and Deploy Jekyll Site
19+
20+
on:
21+
push:
22+
branches:
23+
- master
24+
paths:
25+
- site/**
26+
27+
permissions:
28+
contents: write
29+
30+
jobs:
31+
build-site:
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v2
37+
38+
- name: Set up Ruby
39+
uses: ruby/setup-ruby@v1
40+
with:
41+
ruby-version: '3.2.5'
42+
43+
- name: Set up Node.js
44+
uses: actions/setup-node@v2
45+
with:
46+
# TODO: Lock done a specifc version for node and ruby and define
47+
# it in single place to be shared by this action and /site/Dockerfile
48+
node-version: '20'
49+
50+
- name: Run build script
51+
run: |
52+
cd site/
53+
chmod +x ./build.sh
54+
./build.sh
55+
56+
- name: Remove non-site files
57+
run: |
58+
cp -r site/_site/ /tmp/
59+
rm -rf *
60+
cp -r /tmp/_site/* .
61+
62+
- name: Commit and push to asf-site branch
63+
run: |
64+
git config user.name "GitHub Actions Bot"
65+
git config user.email "<>"
66+
git checkout asf-site
67+
git commit -m "Automatic Site Publish by Buildbot"
68+
git push
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ node_modules/
1010
.npm
1111
npm-debug.log
1212
*.DS_store
13+
./site/_site
14+
.jekyll-cache

site/Dockerfile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@ COPY Gemfile* /tmp/
99
WORKDIR /tmp
1010
RUN bundle install
1111

12-
ENV app=/app
13-
1412
# Install npm modules
1513
COPY package.json /tmp/
1614
WORKDIR /tmp
1715
RUN npm install -g
1816

19-
# Add src code
20-
RUN mkdir $app
21-
WORKDIR $app
22-
ADD . $app
17+
# Add src code and build script
18+
RUN mkdir /app
19+
WORKDIR /app
20+
COPY . /app
21+
22+
# Make the build script executable
23+
RUN chmod +x /app/build.sh
2324

24-
# Jekyll buld
25-
RUN bundle exec jekyll build
25+
# Run the build script
26+
RUN /app/build.sh
2627

27-
WORKDIR $app/_site
28+
WORKDIR /app/_site
2829

29-
EXPOSE 8000
30+
EXPOSE 8000

site/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ DEPENDENCIES
7272
jekyll-feed (~> 0.17.0)
7373

7474
RUBY VERSION
75-
ruby 2.6.10p210
75+
ruby 3.2.3p157
7676

7777
BUNDLED WITH
7878
2.4.22

site/README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,3 @@ How to Build and Deploy Site
1010
```
1111
docker run -p 8000:8000 -it flagon:site python -m http.server
1212
```
13-
4. (Optional): To update the site, can copy the files from the container to `_site`.
14-
```
15-
# First grab container id
16-
CID=$(docker create -p 8000:8000 -it flagon:site python -m http.server)
17-
# Reference container id to grab built contents
18-
docker cp $CID:/app/_site .
19-
```
20-
Then copy files from `_site` in `/site` folder into `/contents` folder.
21-
22-
Merge new website mods at **master** branch with **asf-site** branch to push changes live.

0 commit comments

Comments
 (0)