-
Notifications
You must be signed in to change notification settings - Fork 3
82 lines (67 loc) · 1.63 KB
/
ci.yml
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
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set Node.js
uses: actions/setup-node@master
with:
node-version: 12.x
- uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install dependencies
run: yarn install
- name: Test
run: yarn test
- name: Build 11ty site
run: yarn build
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: site
path: _site/
deploy:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: build
steps:
- name: Write deploy key
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
echo "$DEPLOY_KEY" > /tmp/deploy-key
chmod 0600 /tmp/deploy-key
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: Download artifacts
uses: actions/download-artifact@v1
with:
name: site
path: ./
- name: Init repo
run: |
git init
git config user.email "deployer@github"
git config user.name "Deployer"
- name: Commit
run: |
git add .
git commit -m "Deploy"
- name: Push
env:
GIT_SSH_COMMAND: "ssh -i /tmp/deploy-key"
run: |
git remote add origin git@github.com:$GITHUB_REPOSITORY.git
git push -f origin HEAD:gh-pages