-
-
Notifications
You must be signed in to change notification settings - Fork 2
132 lines (111 loc) · 3.57 KB
/
lucky.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Lucky
on:
push:
branches:
- main
pull_request:
branches:
- "*"
schedule:
- cron: "30 2 * * *"
workflow_dispatch:
jobs:
CheckFormat:
runs-on: ubuntu-latest
container:
image: crystallang/crystal:0.36.1
steps:
- uses: actions/checkout@v2
- name: Format
run: crystal tool format --check
- name: Set up Crystal cache
uses: actions/cache@v2.1.4
id: crystal-cache
with:
path: |
~/.cache/crystal
bin/ameba
lib
key: ${{ runner.os }}-crystal-${{ hashFiles('**/shard.lock') }}
restore-keys: |
${{ runner.os }}-crystal-
- name: Install shards
if: steps.crystal-cache.outputs.cache-hit != 'true'
run: shards check || shards install
- name: Run ameba linter
run: ./bin/ameba
RunSpecs:
runs-on: ubuntu-latest
container:
image: crystallang/crystal:0.36.1
env:
LUCKY_ENV: test
steps:
- uses: actions/checkout@v2
- name: Install Chromedriver
run: |
apt-get update
apt-get -yqq install chromium-chromedriver
- uses: actions/setup-node@v2.1.5
with:
node-version: "12.x"
- name: "Install yarn"
run: npm install -g yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Set up Yarn cache
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Set up Node cache
uses: actions/cache@v2
id: node-cache # use this to check for `cache-hit` (`steps.node-cache.outputs.cache-hit != 'true'`)
with:
path: "**/node_modules"
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set up Crystal cache
uses: actions/cache@v2
id: crystal-cache
with:
path: |
~/.cache/crystal
lib
lucky_tasks
key: ${{ runner.os }}-crystal-${{ hashFiles('**/shard.lock') }}
restore-keys: |
${{ runner.os }}-crystal-
- name: Install shards
if: steps.crystal-cache.outputs.cache-hit != 'true'
run: shards check || shards install
- name: Install yarn packages
if: steps.node-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile --no-progress
- name: Compiling assets
run: yarn prod
- name: Run tests
run: crystal spec
Deploy:
runs-on: ubuntu-latest
needs: [CheckFormat, RunSpecs]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Run Ansible playbook
env:
ANSIBLE_VAULT_PASSWORD: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
SSH_DEPLOY_PRIVATE_KEY: ${{ secrets.SSH_DEPLOY_PRIVATE_KEY }}
run: |
mkdir ~/.ssh
ssh-keyscan -H ${{secrets.SSH_DEPLOY_SERVER_IP}} > ~/.ssh/known_hosts
cd ansible
echo "$SSH_DEPLOY_PRIVATE_KEY" > private-ssh-key
chmod 600 private-ssh-key
echo "$ANSIBLE_VAULT_PASSWORD" > vault-password.txt
ansible-galaxy install -r requirements.yml
ansible-playbook -i production_hosts.yml webserver.yml --vault-password-file vault-password.txt --private-key private-ssh-key