-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (121 loc) · 4.08 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Continuous Integration
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
pre-check:
name: Pre-Check
continue-on-error: true
runs-on: ubuntu-latest
outputs:
images: ${{ steps.map-images.outputs.result }}
steps:
- name: Check for skippable jobs
id: skip-check
uses: fkirc/skip-duplicate-actions@v5
continue-on-error: true
with:
cancel_others: 'true'
paths_ignore: '["**/*.md"]'
paths_filter: |
web:
paths:
- 'web/**/*'
directus:
paths:
- 'directus/**/*'
chatwoot:
paths:
- 'chatwoot/**/*'
- name: Store paths_result output
if: github.event_name != 'push' && steps.skip-check.outputs.paths_result != '{}'
run: echo '${{ steps.skip-check.outputs.paths_result }}' > paths_result
- name: Upload paths_result result
if: github.event_name != 'push' && steps.skip-check.outputs.paths_result != '{}'
uses: actions/upload-artifact@v3
with:
name: paths_result
path: paths_result
- name: Map images
uses: actions/github-script@v6
id: map-images
env:
SKIPPED_BY: ${{ steps.skip-check.outputs.skipped_by }}
PATHS_RESULT: ${{ steps.skip-check.outputs.paths_result }}
with:
script: |
const images = [];
const map = {
web: {
name: 'jaa-web',
context: '.',
file: 'web/Dockerfile'
},
directus: {
name: 'jaa-directus',
context: 'directus',
file: 'Dockerfile'
},
chatwoot: {
name: 'jaa-chatwoot',
context: 'chatwoot',
file: 'Dockerfile'
},
};
let paths_result;
const skipped_by = JSON.parse(process.env.SKIPPED_BY)
if (skipped_by.event) {
if (context.eventName === 'push' && skipped_by.event !== 'push') {
try {
const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: skipped_by.runId
});
const artifact = artifacts.find((artifact) => artifact.name === 'paths_result')
const { data } = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip'
});
const { appendFileSync, readFileSync } = require('fs');
appendFileSync('paths_result.zip', Buffer.from(data));
await exec.exec('unzip', ['paths_result.zip']);
paths_result = JSON.parse(readFileSync('paths_result').toString());
} catch (error) {
core.warning(error);
}
} else {
return images;
}
} else {
paths_result = JSON.parse(process.env.PATHS_RESULT);
}
if (paths_result) {
for (const filter in paths_result) {
if (!paths_result[filter].should_skip && filter in map) {
images.push(map[filter]);
}
}
} else {
for (const name in map) {
images.push(map[name]);
}
}
return images;
build-images:
name: Build Images
needs: pre-check
uses: ./.github/workflows/build-images.yml
with:
images: ${{ needs.pre-check.outputs.images }}
push: ${{ github.event_name == 'push' }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}