Skip to content

Commit 2d251c0

Browse files
Add continuous deployment (#634)
1 parent 8839369 commit 2d251c0

File tree

5 files changed

+53
-6
lines changed

5 files changed

+53
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: deploy
2+
3+
on:
4+
# This event is triggered once per non-Github Actions check-suite. If the only
5+
# check suites we are running are garnix and Github Actions-based ones, this
6+
# will be triggered only once, when garnix is done with all the builds for a
7+
# commit.
8+
check_suite:
9+
types: [completed]
10+
11+
jobs:
12+
deploy:
13+
# Deploys should only occur from the master branch
14+
if: github.ref_name == 'master'
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
21+
- name: Setup SSH keys and known_hosts
22+
env:
23+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
24+
run: |
25+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
26+
ssh-add - <<< "${{ secrets.PACCHETTIBOTTI_SSH_KEY }}"
27+
28+
- name: Install Nix
29+
uses: DeterminateSystems/nix-installer-action@v4
30+
31+
- name: Setup Nix cache
32+
uses: DeterminateSystems/magic-nix-cache-action@v2
33+
34+
- name: Deploy with Colmena
35+
env:
36+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
37+
run: |
38+
nix develop --command colmena apply

CONTRIBUTING.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,17 @@ These checks are also run in the repository continuous integration.
9292

9393
## Deployment
9494

95-
You can deploy a new version of the registry server in one step:
95+
The registry is continuously deployed. The [deploy.yml](./.github/workflows/deploy.yml) file defines a GitHub Actions workflow to auto-deploy the server when a new commit is pushed to `master` and test workflows have passed.
96+
97+
However, you can manually deploy a new version of the registry server in one step:
9698

9799
```sh
98100
# Will deploy the server to registry.purescript.org
99101
colmena apply
100102
```
101103

102-
If the deployment fails it will automatically be rolled back. If you have provisioned a new machine altogether, then you will first need to copy a valid `.env` file to `/var/lib/registry-server/.env` before the server will run. You can test that the server has come up appropriately by SSH-ing into the server and running `journalctl -u server.service`.
104+
If the deployment fails it will automatically be rolled back. You can test that the server has come up appropriately by SSHing into the server and running `journalctl -uf server.service`.
105+
106+
### Updating Secrets
107+
108+
If you have provisioned a new machine or need to update a secret, then you will need to create or edit the `.env` file located in `/var/lib/registry-server`. It follows the same rules as described in the [`.env.example`](./.env.example) file in this repository.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# PureScript Registry Development
22

3+
[![deploy](https://github.com/purescript/registry-dev/actions/workflows/deploy.yml/badge.svg)](https://github.com/purescript/registry-dev/actions/workflows/deploy.yml) [![tests](https://github.com/purescript/registry-dev/actions/workflows/main.yml/badge.svg)](https://github.com/purescript/registry-dev/actions/workflows/main.yml)
4+
35
This repository hosts the code for the PureScript Registry and its affiliated projects. If you are new to the registry and are interested in its development, then the following should be helpful:
46

57
- The [specification](./SPEC.md) describes what the registry is, how it works, and its fundamental types and operations.

flake.nix

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,7 @@
336336
host = "registry.purescript.org";
337337
in {
338338
deployment.targetHost = host;
339-
340-
# Set 'true' to build on the target machine (necessary if deploying
341-
# from a non-linux machine).
342-
deployment.buildOnTarget = false;
339+
deployment.buildOnTarget = true;
343340

344341
# We import the server module and also the digital ocean configuration
345342
# necessary to run in a DO droplet.

nix/deployers.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@
88
fabrizio = {
99
sshKeys = ["ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPqIMvUZf1ffuqlKqemYMrLruO15Hy1SM+We5W1GHI9wLbY6FOsfDL78Yx6Eywc2iU0acpbyr1RVvgJ0gbMbHGc= [email protected]"];
1010
};
11+
12+
pacchettibotti = {
13+
sshKeys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGm5hQeEQS85APheDeSRyggo0Igdq6CbTfq1f8eQG45t [email protected]"];
14+
};
1115
}

0 commit comments

Comments
 (0)