Skip to content

Commit 0e91ff3

Browse files
authored
Add GitHub Actions workflow for production deployment
1 parent 4da58b5 commit 0e91ff3

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Deploy production website
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
concurrency:
10+
group: production-website-deployment
11+
cancel-in-progress: false
12+
13+
jobs:
14+
deploy:
15+
name: Deploy to production
16+
runs-on: ubuntu-latest
17+
environment: production
18+
19+
steps:
20+
- name: Configure SSH
21+
shell: bash
22+
env:
23+
DEPLOY_KEY: ${{ secrets.PRODUCTION_DEPLOY_KEY }}
24+
KNOWN_HOSTS: ${{ secrets.PRODUCTION_KNOWN_HOSTS }}
25+
run: |
26+
set -euo pipefail
27+
install -d -m 700 "${HOME}/.ssh"
28+
printf '%s\n' "${DEPLOY_KEY}" > "${HOME}/.ssh/production-deploy"
29+
chmod 600 "${HOME}/.ssh/production-deploy"
30+
printf '%s\n' "${KNOWN_HOSTS}" > "${HOME}/.ssh/known_hosts"
31+
chmod 600 "${HOME}/.ssh/known_hosts"
32+
33+
- name: Deploy website
34+
shell: bash
35+
env:
36+
DEPLOY_HOST: ${{ vars.PRODUCTION_DEPLOY_HOST }}
37+
run: |
38+
set -euo pipefail
39+
40+
# No password, and no command to execute: this user can ONLY run a single server-side deployment
41+
# script, /usr/local/sbin/deploy-production.sh -- if something about the deployment needs to change,
42+
# a system administrator with access to that path on the webserver must log in to edit it.
43+
ssh \
44+
-i "${HOME}/.ssh/production-deploy" \
45+
-o BatchMode=yes \
46+
-o IdentitiesOnly=yes \
47+
-o StrictHostKeyChecking=yes \
48+
-o UserKnownHostsFile="${HOME}/.ssh/known_hosts" \
49+
production-deploy@"${DEPLOY_HOST}"

0 commit comments

Comments
 (0)