aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 0319d98e65e90b3e99c912ad30b80fdee59d6efb (plain)
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
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Set up Ruby
        uses: ruby/setup-ruby@v1

      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"

      - name: "Cache JS modules"
        uses: actions/cache@v2
        id: yarn-cache
        with:
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-

      - name: "Cache gems"
        uses: actions/cache@v2
        id: gem-cache
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-

      - name: "Install Ruby and Javascript dependencies"
        env:
          RAILS_ENV: "test"
          NODE_ENV: "test"
        run: |
          bundle config set path 'vendor/bundle'
          bundle install --jobs 4 --retry 3
          yarn

      - name: "Build site"
        run: bundle exec jekyll build

      - name: "Run rubocop"
        run: bundle exec rubocop

      - name: "Run tests"
        run: bundle exec rake

      - name: "Create tarball"
        run: tar czvf site.tar.gz _site

      - name: "Upload tarball"
        uses: appleboy/scp-action@master
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          port: ${{ secrets.PORT }}
          key: ${{ secrets.KEY }}
          source: "site.tar.gz"
          target: "test"