-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from clue-labs/build
Add build instructions and auto deployment using GitHub actions
- Loading branch information
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Deploy: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: mkdir -p ~/.ssh && echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_rsa && chmod 400 ~/.ssh/id_rsa | ||
- run: git config --global user.name "GitHub Actions" && git config --global user.email "actions@github.com" | ||
- run: make | ||
- run: git config --global url."https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/" | ||
- run: make deploy | ||
if: ${{ github.ref == 'refs/heads/main' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build/ | ||
/source/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
build: | ||
mkdir -p build/src/ | ||
test -d source/ && git -C source/ pull || git clone git@github.com:clue-access/framework-x.git source/ | ||
docker run --rm -i -v ${PWD}/source:/docs -u $(shell id -u) squidfunk/mkdocs-material build | ||
cp -r source/build/docs/ build/ | ||
cp index.html build/ | ||
cp src/* build/src/ | ||
|
||
serve: build | ||
php -S localhost:8080 -t build/ | ||
|
||
deploy: | ||
git -C build/ init | ||
git -C build/ checkout live 2>/dev/null || git -C build/ checkout -b live | ||
git -C build/ add --all | ||
git -C build/ diff-index HEAD >/dev/null 2>/dev/null || git -C build/ commit -m "Website build" | ||
git -C build/ remote get-url origin >/dev/null 2>/dev/null || git -C build/ remote add origin $(shell git remote get-url origin) | ||
git -C build/ push origin live -f | ||
|
||
clean: | ||
rm -rf source/ build/ | ||
|
||
.PHONY: build serve deploy clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,56 @@ | ||
# Framework X website | ||
|
||
[![CI status](https://github.com/clue/framework-xwebsite/workflows/Deploy/badge.svg)](https://github.com/clue/framework-x-website/actions) | ||
|
||
Source code for the Framework X website. | ||
|
||
## Build | ||
|
||
You can build the website like this: | ||
|
||
```bash | ||
$ make | ||
``` | ||
|
||
> Note that this command will clone Framework X which is currently in early access. | ||
See https://github.com/clue/framework-x for more details. | ||
|
||
Once built, you can manually browse the `build/` directory or run the development | ||
web server like this: | ||
|
||
```bash | ||
$ make serve | ||
``` | ||
|
||
Once built, you can clean up like this: | ||
|
||
```bash | ||
$ make clean | ||
``` | ||
|
||
## Deploy | ||
|
||
Once built (see previous "Build" section), you can simply deploy the `build/` | ||
directory behind a web server of choice. | ||
|
||
The live website is deployed by pushing the contents of the `build/` directory to | ||
the `live` branch like this: | ||
|
||
```bash | ||
$ make deploy | ||
``` | ||
|
||
## Auto-Deployment | ||
|
||
The website can be automatically deployed via the GitHub Pages feature. | ||
|
||
Any time a commit is merged (such as when a PR is merged), GitHub actions will | ||
automatically build and deploy the website. This is done by running the above | ||
deployment script (see previous chapter). | ||
|
||
> Repository setup: | ||
> Note that this command will clone Framework X which is currently in early access. | ||
> We're using a read-only SSH deploy key for reading from this source repository. | ||
> Make sure the required `DEPLOY_KEY` secret is set in the repository settings on GitHub. | ||
> See [action documentation](https://github.com/JamesIves/github-pages-deploy-action#using-an-ssh-deploy-key-) | ||
> for more details. |