Skip to content

Commit

Permalink
Migrate CI workflow from CircleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
sau226 committed Dec 30, 2022
1 parent e55f057 commit c3d3685
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 125 deletions.
125 changes: 0 additions & 125 deletions .circleci/config.yml

This file was deleted.

117 changes: 117 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Test, lint and deploy
on:
push:
branches:
- develop
jobs:
test:
defaults:
run:
working-directory: "~/qpixel"
runs-on: ubuntu-latest
container:
image: cimg/ruby:2.7-node
services:
mysql:
image: cimg/mysql:8.0
env:
MYSQL_ROOT_HOST: "%"
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: qpixel_test
options: " --default-authentication-plugin=mysql_native_password"
redis:
image: cimg/redis:7.0
steps:
- name: Install packages
run: |-
sudo apt-get --allow-releaseinfo-change -qq update
sudo apt-get -y install git libmariadb-dev libmagickwand-dev
- uses: actions/[email protected]
- name: restore_cache
uses: actions/cache@v3
with:
key: qpixel-{{ checksum "Gemfile" }}
restore-keys: |-
qpixel-{{ checksum "Gemfile" }}
qpixel-
path: "~/gems"
- name: Install Bundler & gems
run: |-
gem install bundler
bundle install --path=~/gems
- name: Copy key
env:
MASTER_KEY: ${{ secrets.MASTER_KEY }}
run: echo "$MASTER_KEY" > config/master.key
- name: Prepare config & database
run: |-
cp config/database.sample.yml config/database.yml
cp config/storage.sample.yml config/storage.yml
bundle exec rails db:create
bundle exec rails db:schema:load
bundle exec rails db:migrate
bundle exec rails test:prepare
env:
RAILS_ENV: test
- name: Current revision
run: git rev-parse $(git rev-parse --abbrev-ref HEAD)
- name: Coveralls token
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: 'echo "repo_token: $COVERALLS_REPO_TOKEN" > .coveralls.yml'
- name: Test
run: bundle exec rails test
- uses: actions/[email protected]
with:
path: "~/qpixel/test/reports"
rubocop:
defaults:
run:
working-directory: "~/qpixel"
runs-on: ubuntu-latest
container:
image: cimg/ruby:2.7-node
steps:
- name: Install packages
run: |-
sudo apt-get --allow-releaseinfo-change -qq update
sudo apt-get -y install git libmariadb-dev libmagickwand-dev
- uses: actions/[email protected]
- name: restore_cache
uses: actions/cache@v3
with:
key: qpixel-{{ checksum "Gemfile" }}
restore-keys: |-
qpixel-{{ checksum "Gemfile" }}
qpixel-
path: "~/gems"
- name: Install Bundler & gems
run: |-
gem install bundler
bundle install --path=~/gems
- name: Rubocop
run: bundle exec rubocop
deploy:
if: github.ref == 'refs/heads/develop'
defaults:
run:
working-directory: "~/qpixel"
runs-on: ubuntu-latest
container:
image: cimg/ruby:2.7-node
needs:
- test
- rubocop
steps:
- name: Import SSH key
env:
DEV_SSH_KEY: ${{ secrets.DEV_SSH_KEY }}
run: |-
echo "$DEV_SSH_KEY" | base64 --decode > ~/deploy.key
chmod 0700 ~/deploy.key
- name: Run deploy
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_IP: ${{ secrets.SSH_IP }}
SSH_PORT: ${{ secrets.SSH_PORT }}
run: ssh -o 'StrictHostKeyChecking no' "$SSH_USER"@"$SSH_IP" -p "$SSH_PORT" -i ~/deploy.key "sudo su -l qpixel /var/apps/deploy-dev"

0 comments on commit c3d3685

Please sign in to comment.