Skip to content

Commit 406aa5b

Browse files
committed
Change auto deployment to use GitHub actions
1 parent 65f8a16 commit 406aa5b

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ name: CI
33
on:
44
push:
55
pull_request:
6+
workflow_dispatch:
67

78
jobs:
8-
Acceptance:
9+
Deploy:
910
runs-on: ubuntu-22.04
1011
strategy:
1112
matrix:
@@ -20,3 +21,7 @@ jobs:
2021
- run: make
2122
- run: make served
2223
- run: make test
24+
- run: git config --global user.name "GitHub Actions" && git config --global user.email "actions@github.com"
25+
- run: git config --global url."https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
26+
- run: make deploy
27+
if: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ test:
2424
bash tests/acceptance.sh
2525
test -z "$$(git status --porcelain)" || (echo Directory is dirty && git status && exit 1)
2626

27+
deploy:
28+
git -C build/ init
29+
git -C build/ checkout live 2>/dev/null || git -C build/ checkout -b live
30+
git -C build/ add --all
31+
git -C build/ diff-index HEAD >/dev/null 2>/dev/null || git -C build/ commit -m "Website build"
32+
git -C build/ remote get-url origin >/dev/null 2>/dev/null || git -C build/ remote add origin $(shell git remote get-url origin)
33+
git -C build/ push origin live -f
34+
2735
clean:
2836
rm -rf build/ vendor/ tailwindcss
2937

30-
.PHONY: build serve served test clean
38+
.PHONY: build serve served test deploy clean

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# clue.engineering
22

3+
[![CI status](https://github.com/clue/clue.engineering/workflows/Deploy/badge.svg)](https://github.com/clue/clue.engineering/actions)
4+
[![Last deployed on `live`](https://img.shields.io/github/last-commit/clue/clue.engineering/live?label=last%20deployed&logo=github)](https://github.com/clue/clue.engineering/tree/live)
5+
36
Source code for the https://clue.engineering/ website.
47

58
## Build
@@ -53,3 +56,16 @@ Additionally, this should be deployed behind a reverse proxy (nginx) that is
5356
responsible for HTTPS certificate handling and forcing HTTPS redirects.
5457

5558
Additionally, Apache has been configured to cache static files for 1 day.
59+
60+
The live website is deployed by pushing the contents of the `build/` directory to
61+
the `live` branch like this:
62+
63+
```bash
64+
make deploy
65+
```
66+
67+
## Auto-Deployment
68+
69+
Any time a commit is merged (such as when a PR is merged), GitHub actions will
70+
automatically build and deploy the website. This is done by running the above
71+
deployment script (see previous chapter).

0 commit comments

Comments
 (0)