Skip to content

Commit 0b00924

Browse files
committed
Automatically deploy site
1 parent 50a13c7 commit 0b00924

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

.github/workflows/deploy.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy
2+
3+
# We deploy the site *only* on
4+
#
5+
# 1. A push to master, or
6+
# 2. A manually triggered Deploy build
7+
#
8+
# We don't want to deploy for every branch and PR of course!
9+
on:
10+
push:
11+
branches:
12+
- master
13+
workflow_dispatch:
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Install Nix
23+
uses: cachix/install-nix-action@v12
24+
25+
# The CI Github Action also builds the site and puts it in an
26+
# artifact. However, downloading an artifact from a different
27+
# workflow seems to be difficult.
28+
#
29+
# https://github.com/actions/download-artifact/issues/3
30+
#
31+
# We'll just build the whole site again here. It only takes a
32+
# couple of minutes.
33+
- name: Build Site
34+
# we run the checks as a separate step
35+
run: nix build -f . built -o built-site --arg doCheck false
36+
37+
- name: Check Links
38+
run: nix run --quiet -f . linkchecker -c linkchecker built-site
39+
40+
- name: Deploy
41+
shell: bash
42+
env:
43+
# Create the secret with:
44+
#
45+
# Settings -> Secrets -> New Repository Secret ->
46+
#
47+
# Name: WWW_HASKELL_ORG_SSH_KEY
48+
# Value: The text of the ssh private key
49+
WWW_HASKELL_ORG_SSH_KEY: ${{ secrets.WWW_HASKELL_ORG_SSH_KEY }}
50+
run: |
51+
nix run --quiet -f . lftp -c sh ./deploy.sh --DEPLOY-IT-LIVE

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@ You may then run the builder binary from the `result` directory:
7676
```
7777
./result/bin/haskell-org-site build
7878
```
79+
80+
### Deploying
81+
82+
The site will automatically be deployed live to <http://www.haskell.org/> every time a branch is merged to `master`. Alternatively an admin for this GitHub repository can deploy the site by visiting the [Deploy workflow page](https://github.com/haskell-infra/www.haskell.org/actions/workflows/deploy.yml), clicking the "Run workflow" dropdown, choosing the branch to build and deploy, and clicking the "Run workflow" button.

default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ let
3333
};
3434
in
3535
if pkgs.lib.inNixShell then builder
36-
else { inherit builder built; inherit (pkgs) linkchecker; }
36+
else { inherit builder built; inherit (pkgs) linkchecker lftp; }

deploy.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
# TODO: make this with tempfile
4+
KEYFILE=__TEMP_INPUT_KEY_FILE
5+
6+
echo "${WWW_HASKELL_ORG_SSH_KEY}" > "$KEYFILE"
7+
chmod 600 "$KEYFILE"
8+
9+
if [ "$1" = --DEPLOY-IT-LIVE ]; then
10+
DESTINATION=www
11+
else
12+
DESTINATION=www-test
13+
fi
14+
15+
# WARNING: --delete is dangerous. Be absolutely sure you are
16+
# deploying to the correct directory. Existing contents of the
17+
# destination directory will be removed.
18+
#
19+
# Permissions: We have to recursively set write permissions because
20+
# lftp isn't able to remove a file if its directory is not writeable.
21+
lftp --norc -c "set net:max-retries 1; set sftp:connect-program \"ssh -o StrictHostKeyChecking=no -a -x -i $KEYFILE\"; open -u www-sftp, sftp://webhost.haskell.org; chmod --recursive u+w $DESTINATION; mirror --delete --verbose --reverse --transfer-all built-site $DESTINATION"

0 commit comments

Comments
 (0)