Skip to content

Commit 74b5b19

Browse files
committed
Change auto deployment to use GitHub actions
1 parent 65f8a16 commit 74b5b19

3 files changed

Lines changed: 27 additions & 3 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: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,15 @@ directory behind your favorite web server (Apache + PHP-FPM etc.).
5252
Additionally, this should be deployed behind a reverse proxy (nginx) that is
5353
responsible for HTTPS certificate handling and forcing HTTPS redirects.
5454

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

0 commit comments

Comments
 (0)