Skip to content

Commit

Permalink
Merge pull request #7 from clue-labs/build
Browse files Browse the repository at this point in the history
Add build instructions and auto deployment using GitHub actions
  • Loading branch information
clue authored Aug 6, 2021
2 parents d3b3ee6 + 8061642 commit d19b5b7
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
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' }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/
/source/
23 changes: 23 additions & 0 deletions Makefile
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
55 changes: 55 additions & 0 deletions README.md
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.

0 comments on commit d19b5b7

Please sign in to comment.