Skip to content

Commit a3a0422

Browse files
committed
ci, docs: rebuild on awesome-gbdev changes, add CONTRIBUTING.md (#8)
CI: - Run the deploy workflow on an `awesome-gbdev-updated` repository_dispatch event, sent by awesome-gbdev when its README changes, and on manual workflow_dispatch. - Serialize deploys with a concurrency group, so a push and a dispatch can't push to master at the same time. - Skip the deploy commit when the build output is unchanged, instead of failing on an empty commit. Docs: - Move the resources page instructions from README.md to a new CONTRIBUTING.md, linked from the README. - Document when the website is deployed and the token awesome-gbdev uses to trigger the deploy, pointing to awesome-gbdev's CONTRIBUTING.md for the sending side.
1 parent b75bc99 commit a3a0422

3 files changed

Lines changed: 47 additions & 27 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ name: CI
33
on:
44
push:
55
branches: [ dev ]
6+
# Sent by awesome-gbdev when its README changes, to rebuild the resources page
7+
repository_dispatch:
8+
types: [ awesome-gbdev-updated ]
9+
workflow_dispatch:
10+
11+
# Don't let two deploys push to master at the same time
12+
concurrency:
13+
group: deploy
14+
cancel-in-progress: false
615

716
jobs:
817
build:
@@ -67,5 +76,9 @@ jobs:
6776
git remote -v
6877
git branch -v
6978
git add -A
70-
git commit -am 'Update build'
79+
if git diff --cached --quiet; then
80+
echo "Build output unchanged, nothing to deploy."
81+
exit 0
82+
fi
83+
git commit -m 'Update build'
7184
git push -v

‎CONTRIBUTING.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Contributing
2+
3+
## Resources page
4+
5+
`website/resources.md` (served at [gbdev.io/resources](https://gbdev.io/resources)) is not committed: it's generated from the [awesome-gbdev](https://github.com/gbdev/awesome-gbdev) README by `yarn build-resources`. The website-only top of the page (front matter, videos, notes) lives in [`scripts/resources/header.md`](scripts/resources/header.md), and everything between the `<!-- gbdev.io:begin body -->` and `<!-- gbdev.io:end body -->` markers of the awesome-gbdev README is appended to it.
6+
7+
By default the README is fetched from the master branch of awesome-gbdev. Run this before `yarn dev`, and again whenever you want to pull in changes to the list (requires Node 18 or later):
8+
9+
```bash
10+
# From the master branch of awesome-gbdev
11+
yarn build-resources
12+
13+
# From a specific branch, tag or commit
14+
yarn build-resources 0c457e7833cd22985976dc0eecc859919ae589b0
15+
16+
# From a local copy of the README (e.g. to preview changes to the list md)
17+
yarn build-resources ../awesome-gbdev/README.md
18+
```
19+
20+
`yarn build` runs `yarn build-resources` automatically before building. By default (when `RESOURCES_MD_SRC` is not set) the script fetches the README from the master branch of awesome-gbdev on GitHub by itself, so deployed builds always use the current list. To build from another source instead, set the `RESOURCES_MD_SRC` environment variable to any of the values accepted by `yarn build-resources` (a branch, tag, commit or local path):
21+
22+
```bash
23+
# Fetches the README from awesome-gbdev master
24+
yarn build
25+
26+
# Uses a local copy of the README instead
27+
RESOURCES_MD_SRC=../awesome-gbdev/README.md yarn build
28+
```
29+
30+
## CI
31+
32+
The website is rebuilt and deployed on every push to `dev`, and also whenever the awesome-gbdev README changes: awesome-gbdev sends an `awesome-gbdev-updated` [`repository_dispatch`](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#repository_dispatch) event to this repository, which runs the deploy workflow. To do so, awesome-gbdev holds a fine-grained token with access to this repository (Contents: read and write): if it expires or is revoked, the resources page stops updating until the next push here. How the event is sent is documented in the [awesome-gbdev CONTRIBUTING.md](https://github.com/gbdev/awesome-gbdev/blob/master/CONTRIBUTING.md). A deploy may also be started manually from the Actions tab ("Run workflow").

‎README.md‎

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,4 @@ yarn dev
1818
yarn build
1919
```
2020

21-
## Resources page
22-
23-
`website/resources.md` (served at [gbdev.io/resources](https://gbdev.io/resources)) is not committed: it's generated from the [awesome-gbdev](https://github.com/gbdev/awesome-gbdev) README by `yarn build-resources`. The website-only top of the page (front matter, videos, notes) lives in [`scripts/resources/header.md`](scripts/resources/header.md), and everything between the `<!-- gbdev.io:begin body -->` and `<!-- gbdev.io:end body -->` markers of the awesome-gbdev README is appended to it.
24-
25-
By default the README is fetched from the master branch of awesome-gbdev. Run this before `yarn dev`, and again whenever you want to pull in changes to the list (requires Node 18 or later):
26-
27-
```bash
28-
# From the master branch of awesome-gbdev
29-
yarn build-resources
30-
31-
# From a specific branch, tag or commit
32-
yarn build-resources 0c457e7833cd22985976dc0eecc859919ae589b0
33-
34-
# From a local copy of the README (e.g. to preview changes to the list md)
35-
yarn build-resources ../awesome-gbdev/README.md
36-
```
37-
38-
`yarn build` runs `yarn build-resources` automatically before building. By default (when `RESOURCES_MD_SRC` is not set) the script fetches the README from the master branch of awesome-gbdev on GitHub by itself, so deployed builds always use the current list. To build from another source instead, set the `RESOURCES_MD_SRC` environment variable to any of the values accepted by `yarn build-resources` (a branch, tag, commit or local path):
39-
40-
```bash
41-
# Fetches the README from awesome-gbdev master
42-
yarn build
43-
44-
# Uses a local copy of the README instead
45-
RESOURCES_MD_SRC=../awesome-gbdev/README.md yarn build
46-
```
21+
See [CONTRIBUTING.md](CONTRIBUTING.md) to learn how to contribute to the website, including how the resources page is generated.

0 commit comments

Comments
 (0)