Repository navigation
77 lines (73 loc) · 2.35 KB
/
Copy pathdeploy-staging.yml
File metadata and controls
77 lines (73 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: CI & staging deploy
on:
push:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/staging' }}
jobs:
check:
name: Typecheck, tests & build
runs-on: ubuntu-latest
services:
postgres:
image: postgres:18-alpine
env:
POSTGRES_USER: jscm
POSTGRES_PASSWORD: jscm
POSTGRES_DB: jscm_test
ports: ['5432:5432']
options: >-
--health-cmd "pg_isready -U jscm -d jscm_test"
--health-interval 5s
--health-timeout 5s
--health-retries 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- run: npm ci
- name: Prepare environment
run: |
cp .env.example .env
sed -i "s/^APP_KEY=.*/APP_KEY=$(openssl rand -hex 32)/" .env
- run: npm run typecheck
- run: node ace test
- run: node ace build
deploy:
name: Deploy to staging.javascript.cm
needs: check
if: github.event_name == 'push' && github.ref == 'refs/heads/staging'
runs-on: ubuntu-latest
concurrency:
group: staging-deploy
cancel-in-progress: false
environment:
name: staging
url: https://staging.javascript.cm
steps:
- name: Check deploy secrets
id: secrets
env:
HOST: ${{ secrets.STAGING_HOST }}
run: |
if [ -z "$HOST" ]; then
echo "::warning title=Deploy skipped::STAGING_SSH_KEY, STAGING_KNOWN_HOSTS, STAGING_HOST and STAGING_SSH_USER secrets are not configured."
echo "ready=false" >> "$GITHUB_OUTPUT"
else
echo "ready=true" >> "$GITHUB_OUTPUT"
fi
- name: Configure SSH
if: steps.secrets.outputs.ready == 'true'
run: |
install -m 700 -d ~/.ssh
echo "${{ secrets.STAGING_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
echo "${{ secrets.STAGING_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
# The key is restricted server-side (forced command): it can only run the deploy script.
- name: Deploy
if: steps.secrets.outputs.ready == 'true'
run: ssh -i ~/.ssh/deploy_key ${{ secrets.STAGING_SSH_USER }}@${{ secrets.STAGING_HOST }} deploy