Repository navigation
95 lines (88 loc) · 3.14 KB
/
Copy pathci.yml
File metadata and controls
95 lines (88 loc) · 3.14 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
# A newer push cancels a stale PR run, but runs on main finish so a deploy is never cut off.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
NEXT_TELEMETRY_DISABLED: "1"
jobs:
checks:
name: Lint, typecheck, unit tests, build
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run lint
- run: npm run typecheck
- run: npm test
- run: npm run build
e2e:
name: Playwright E2E
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
cache: npm
- run: npm ci
# The runner's full Chrome matches the full Chromium used locally. Playwright's
# bundled headless shell draws classic scrollbars, which narrow 320 px layouts.
- run: npx playwright test
env:
PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH: /usr/bin/google-chrome
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: playwright-report
path: playwright-report/
retention-days: 7
deploy:
name: Deploy to www.stackhatch.io
needs: [checks, e2e]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 20
environment:
name: production
url: https://www.stackhatch.io
concurrency:
group: deploy-production
cancel-in-progress: false
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Build image
run: docker build -t "stackhatch:${GITHUB_SHA}" .
- name: Configure SSH
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
run: |
install -m 700 -d ~/.ssh
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > ~/.ssh/known_hosts
# The key may run only scripts/deploy-stackhatch.sh on the host: the SHA becomes
# SSH_ORIGINAL_COMMAND and the image arrives on stdin.
- name: Ship image and swap container
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
run: |
docker save "stackhatch:${GITHUB_SHA}" | gzip |
ssh -i ~/.ssh/deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes \
"root@${DEPLOY_HOST}" "${GITHUB_SHA}"
- name: Check the live site
run: curl --fail --silent --show-error --retry 5 --retry-delay 3 -o /dev/null https://www.stackhatch.io/