forked from nimblehq/rails-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (64 loc) · 2.15 KB
/
test_production_build.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
name: Test Production Docker Build
on: push
env:
APP_NAME: rails-templates
DOCKER_IMAGE: ${{ github.repository }}
DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }}
RUBY_VERSION: 3.3.1
NODE_VERSION: 22
RAILS_VERSION: 7.1.3
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_production:
name: ${{ matrix.variant }} variant
runs-on: ubuntu-latest
strategy:
matrix:
variant: [web, api]
steps:
- uses: actions/checkout@v3
- name: Set env BRANCH_TAG
uses: nimblehq/branch-tag-action@1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache gems
uses: actions/cache@v3
with:
path: /home/runner/.rubies/ruby-${{ env.RUBY_VERSION }}
key: ${{ runner.os }}-gems-${{ env.RUBY_VERSION }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-${{ env.RUBY_VERSION }}-
- name: Create app folder
run: mkdir $APP_NAME
- name: Get yarn cache directory path
if: ${{ matrix.variant == 'web' }}
id: yarn-cache-dir-path
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache npm packages
if: ${{ matrix.variant == 'web' }}
uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }}
**/yarn.lock
**/node_modules
key: ${{ runner.os }}-npm-packages-${{ hashFiles('**/package.json*') }}
restore-keys: |
${{ runner.os }}-npm-packages-
- name: Create rails app
run: |
gem install rails -v ${{ env.RAILS_VERSION }} --no-document
make create_${{ matrix.variant }}
- name: Build production image
run: |
export BRANCH_TAG=${{ env.BRANCH_TAG }}-${{ matrix.variant }}
make build_production