Skip to content

Commit f50589e

Browse files
authored
Merge pull request #29 from herablog/feat/bundle
[experimental] ci: 📦 create workflow to publish guideline as web bundle
2 parents 321321b + 2ab6c8a commit f50589e

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

.github/workflows/gh-pages.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Publish Web Bundle
2+
3+
on:
4+
# Our web bundle is published manually now,
5+
# but this trigger is going to be changed to an event that guideline has been updated
6+
push:
7+
branches:
8+
- publish-webbundle
9+
10+
jobs:
11+
build-publish:
12+
runs-on: ubuntu-18.04
13+
env:
14+
TZ: Asia/Tokyo
15+
BUNDLE_NAME: ameba-accessibility-guidelines.wbn
16+
steps:
17+
- uses: actions/checkout@v1
18+
with:
19+
ref: ${{ github.ref }}
20+
21+
- name: Setup Node
22+
uses: actions/setup-node@v1
23+
with:
24+
node-version: 12
25+
26+
- name: Setup Hugo
27+
uses: peaceiris/[email protected]
28+
with:
29+
hugo-version: 0.55.6
30+
31+
- name: Build Site
32+
run: |
33+
npm install
34+
npm run build
35+
36+
- name: Build Hugo
37+
run: hugo --minify
38+
39+
- name: Install go/bundle CLI
40+
run: |
41+
# Go has been installed at the setup hugo step,
42+
# you can run setup-go action if you want to install specific version
43+
go get -u github.com/WICG/webpackage/go/bundle/cmd/gen-bundle
44+
# Add path to run the package
45+
echo "::add-path::$HOME/go/bin"
46+
47+
- name: Generate Web Bundle 📦
48+
run: |
49+
# Create URL list from the files built by Hugo
50+
# - directory index: replacing /index.html with ''
51+
# - URL should be exactly the same with the link text in the document
52+
# - remove empty lines
53+
# - add hosting domain
54+
find public -type f | sed -e 's|/index.html||g' -e '/^$/d' -e 's|public|https://openameba.github.io/a11y-guidelines|g' > urls.txt
55+
# Add extra dependencies
56+
echo -e 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/styles/a11y-light.min.css \nhttps://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/highlight.min.js' >> urls.txt
57+
# Generate web bundle from URL list by following reasons:
58+
# - static directory is different from a web server implementation e.g. directory index
59+
# - to ensure HTTP response headers
60+
gen-bundle -URLList urls.txt -primaryURL https://openameba.github.io/a11y-guidelines -o ${{ env.BUNDLE_NAME }}
61+
62+
- name: Generate Release ID
63+
id: generate-release-id
64+
run: |
65+
d=`date +%Y%m%d%H%M%S`
66+
echo "::set-output name=release_id::$d"
67+
68+
- name: Create Release
69+
id: create-release
70+
uses: actions/[email protected]
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
with:
74+
tag_name: webbundle-${{ steps.generate-release-id.outputs.release_id }}
75+
# I am waiting for https://github.com/actions/create-release/pull/19 has been merged
76+
target_commitish: ${{ github.ref }}
77+
release_name: Release Web Bundle ${{ steps.generate-release-id.outputs.release_id }}
78+
body: |
79+
📦 New version of web bundle has been published. This means
80+
81+
- you can read our accessibility guideline **offline**
82+
- you can send our accessibility guideline to your a11y friends
83+
84+
Please download our web bundle named ${{ env.BUNDLE_NAME }} from the link below and check [web.dev](https://web.dev/web-bundles/#playing-around-with-web-bundles) to try out this bundle.
85+
draft: false
86+
prerelease: false
87+
88+
- name: Upload Release Asset
89+
uses: actions/[email protected]
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
with:
93+
upload_url: ${{ steps.create-release.outputs.upload_url }}
94+
asset_path: ./${{ env.BUNDLE_NAME }}
95+
asset_name: ${{ env.BUNDLE_NAME }}
96+
asset_content_type: application/webbundle

0 commit comments

Comments
 (0)