Skip to content

Commit 6d016bb

Browse files
authored
ci: migrate from CircleCI to GitHub Actions (#321)
* ci: migrate from CircleCI to GitHub Actions CircleCI has been unable to check out the repository since its checkout key stopped working, so nothing has been deployed since 2023-10. Replace it with GitHub Actions and publish through the Pages deployment API instead of committing the build output to the master branch. - add .github/workflows/deploy.yml (build on every push/PR, deploy to Pages on source) - drop .circleci/config.yml and update.sh - drop rimraf and status-back, only used by the two files above - bump .node-version from 8.1.4 to 24, the current LTS - fix bulbofile.js for the ESM majors of gulp-nunjucks and gulp-markdown pulled in by #312 and #313, which broke the build - emit CNAME into build/ so the custom domain survives in the artifact * ci: publish to master instead of GitHub Pages nodejs.jp turns out to be served by Netlify out of the master branch, not by GitHub Pages, so deploying through the Pages API would not touch the live site. Replace the Pages deploy job with one that builds into a checkout of master and pushes, which is what update.sh did under CircleCI.
1 parent d5ec3a3 commit 6d016bb

7 files changed

Lines changed: 80 additions & 303 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: build & deploy
2+
3+
on:
4+
push:
5+
branches: [source]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
# Let a running deploy finish rather than cancelling it half way.
13+
concurrency:
14+
group: deploy
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v7
22+
- uses: actions/setup-node@v7
23+
with:
24+
node-version-file: .node-version
25+
cache: npm
26+
- run: npm ci
27+
- run: npm run build
28+
# Uploaded on pull requests too, so the built site can be downloaded
29+
# from the run page for review.
30+
- uses: actions/upload-artifact@v7
31+
with:
32+
name: site
33+
path: build
34+
35+
# nodejs.jp is served by Netlify out of the master branch, so publishing
36+
# means committing the build output there. This mirrors the update.sh that
37+
# CircleCI used to run.
38+
deploy:
39+
needs: build
40+
if: github.event_name != 'pull_request'
41+
runs-on: ubuntu-latest
42+
permissions:
43+
contents: write
44+
steps:
45+
- uses: actions/checkout@v7
46+
- uses: actions/setup-node@v7
47+
with:
48+
node-version-file: .node-version
49+
cache: npm
50+
- run: npm ci
51+
- name: Check out master as the build destination
52+
run: |
53+
git clone --depth 1 -b master \
54+
"https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" \
55+
build
56+
- run: npm run build
57+
- name: Commit and push
58+
working-directory: build
59+
run: |
60+
git config user.name 'github-actions[bot]'
61+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
62+
git add -A
63+
if git diff --cached --quiet; then
64+
echo 'nothing to publish'
65+
exit 0
66+
fi
67+
git commit -m 'chore(site): automated update from github actions'
68+
git push origin HEAD:master

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.1.4
1+
24

bulbofile.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ const asset = bulbo.asset
33

44
const path = require('path')
55
const frontMatter = require('gulp-front-matter')
6-
const nunjucks = require('gulp-nunjucks')
7-
const markdown = require('gulp-markdown')
6+
// gulp-nunjucks v6 / gulp-markdown v8 are ESM. require() of ESM is supported
7+
// on Node 22.12+ so we read the named / default exports off the namespace.
8+
const {nunjucksCompile} = require('gulp-nunjucks')
9+
const markdown = require('gulp-markdown').default
810
const wrapper = require('layout-wrapper')
911
const accumulate = require('vinyl-accumulate')
1012
const branch = require('branch-pipe')
@@ -35,7 +37,7 @@ const layout = defaultLayout => wrapper.nunjucks({
3537
asset('source/**/*.md', '!source/{events,jobs,news}/**/*')
3638
.watch('source/**/*.{md,njk}')
3739
.pipe(frontMatter({property: 'fm'}))
38-
.pipe(nunjucks.compile(data))
40+
.pipe(nunjucksCompile(data))
3941
.pipe(markdown())
4042
.pipe(layout('default'))
4143

@@ -128,3 +130,7 @@ asset('source/pdfs/**/*.pdf')
128130

129131
// Old site is available under http://nodejs.jp/old/
130132
asset('./old/*.*').base('./')
133+
134+
// Keep CNAME in the published output rather than relying on the copy that
135+
// happens to sit in master
136+
asset('./CNAME').base('./')

0 commit comments

Comments
 (0)