-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (75 loc) · 2.57 KB
/
ci.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
---
name: Continous Integration - CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: buildx
uses: docker/setup-buildx-action@master
- name: prepare artifacts
run: mkdir -p artifacts
- name: docker login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: docker build test
uses: docker/build-push-action@v4
with:
context: .
load: true
push: false
target: test
tags: ghcr.io/${{ github.repository }}-test:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: docker build target
uses: docker/build-push-action@v4
with:
context: .
load: true
push: false
target: production
tags: ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
# build-args:
# FOOTER_VERSION: "${{ github.ref_name }}"
- name: migrate
run: docker-compose --file docker-compose.ci.yml run e2e_target bin/rails db:drop db:create db:migrate
- name: migrate
run: docker-compose --file docker-compose.ci.yml up -d e2e_target
- name: bin/check
run: docker-compose --file docker-compose.ci.yml run e2e_test bin/check
- if: github.event_name != 'pull_request'
name: docker tag
run: docker tag ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:${{ github.ref_name }}
- if: github.event_name != 'pull_request'
name: docker push
run: docker push ghcr.io/${{ github.repository }}:${{ github.ref_name }}
# uses: docker/build-push-action@v3
# with:
# push: true
# tags: "ghcr.io/${{ github.repository }}:${{ github.ref_name }}"
# cache-from: type=gha
# cache-to: type=gha,mode=max
- if: failure()
name: dump log
run: docker compose --file docker-compose.ci.yml logs > ./artifacts/docker-compose.ci.log
- if: failure()
name: dump tmp
run: docker compose --file docker-compose.ci.yml cp e2e_test:/rails/tmp ./artifacts/tmp
- if: failure()
name: upload artifacts
uses: actions/upload-artifact@master
with:
name: artifacts
path: artifacts