Skip to content

Commit 6530f40

Browse files
committed
Migrate CI workflow from CircleCI
1 parent ad595c3 commit 6530f40

File tree

2 files changed

+113
-125
lines changed

2 files changed

+113
-125
lines changed

.circleci/config.yml

Lines changed: 0 additions & 125 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Test, lint and deploy
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
jobs:
7+
test:
8+
defaults:
9+
run:
10+
working-directory: "~/qpixel"
11+
runs-on: ubuntu-latest
12+
container:
13+
image: cimg/ruby:2.7-node
14+
services:
15+
mysql:
16+
image: cimg/mysql:8.0
17+
env:
18+
MYSQL_ROOT_HOST: "%"
19+
MYSQL_ROOT_PASSWORD: root
20+
MYSQL_DATABASE: qpixel_test
21+
options: " --default-authentication-plugin=mysql_native_password"
22+
redis:
23+
image: cimg/redis:7.0
24+
steps:
25+
- name: Install packages
26+
run: |-
27+
sudo apt-get --allow-releaseinfo-change -qq update
28+
sudo apt-get -y install git libmariadb-dev libmagickwand-dev
29+
- uses: actions/checkout@v3.1.0
30+
- name: restore_cache
31+
uses: actions/cache@v3
32+
with:
33+
key: qpixel-{{ checksum "Gemfile" }}
34+
restore-keys: |-
35+
qpixel-{{ checksum "Gemfile" }}
36+
qpixel-
37+
path: "~/gems"
38+
- name: Install Bundler & gems
39+
run: |-
40+
gem install bundler
41+
bundle install --path=~/gems
42+
- name: Copy key
43+
env:
44+
MASTER_KEY: ${{ secrets.MASTER_KEY }}
45+
run: echo "$MASTER_KEY" > config/master.key
46+
- name: Prepare config & database
47+
run: |-
48+
cp config/database.sample.yml config/database.yml
49+
cp config/storage.sample.yml config/storage.yml
50+
bundle exec rails db:create
51+
bundle exec rails db:schema:load
52+
bundle exec rails db:migrate
53+
bundle exec rails test:prepare
54+
env:
55+
RAILS_ENV: test
56+
- name: Current revision
57+
run: git rev-parse $(git rev-parse --abbrev-ref HEAD)
58+
- name: Coveralls token
59+
env:
60+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
61+
run: 'echo "repo_token: $COVERALLS_REPO_TOKEN" > .coveralls.yml'
62+
- name: Test
63+
run: bundle exec rails test
64+
- uses: actions/upload-artifact@v3.1.1
65+
with:
66+
path: "~/qpixel/test/reports"
67+
rubocop:
68+
defaults:
69+
run:
70+
working-directory: "~/qpixel"
71+
runs-on: ubuntu-latest
72+
container:
73+
image: cimg/ruby:2.7-node
74+
steps:
75+
- name: Install packages
76+
run: |-
77+
sudo apt-get --allow-releaseinfo-change -qq update
78+
sudo apt-get -y install git libmariadb-dev libmagickwand-dev
79+
- uses: actions/checkout@v3.1.0
80+
- name: restore_cache
81+
uses: actions/cache@v3
82+
with:
83+
key: qpixel-{{ checksum "Gemfile" }}
84+
restore-keys: |-
85+
qpixel-{{ checksum "Gemfile" }}
86+
qpixel-
87+
path: "~/gems"
88+
- name: Install Bundler & gems
89+
run: |-
90+
gem install bundler
91+
bundle install --path=~/gems
92+
- name: Rubocop
93+
run: bundle exec rubocop
94+
deploy:
95+
if: github.ref == 'refs/heads/develop'
96+
defaults:
97+
run:
98+
working-directory: "~/qpixel"
99+
runs-on: ubuntu-latest
100+
container:
101+
image: cimg/ruby:2.7-node
102+
needs:
103+
- test
104+
- rubocop
105+
steps:
106+
- name: Import SSH key
107+
env:
108+
DEV_SSH_KEY: ${{ secrets.DEV_SSH_KEY }}
109+
run: |-
110+
echo "$DEV_SSH_KEY" | base64 --decode > ~/deploy.key
111+
chmod 0700 ~/deploy.key
112+
- name: Run deploy
113+
run: ssh -o 'StrictHostKeyChecking no' "$SSH_USER"@"$SSH_IP" -p "$SSH_PORT" -i ~/deploy.key "sudo su -l qpixel /var/apps/deploy-dev"

0 commit comments

Comments
 (0)