-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (66 loc) · 2.36 KB
/
test.yaml
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
name: GH actions testing
run-name: GH actions testing
on: [push]
jobs:
get-changes-for-envs:
runs-on: ubuntu-latest
timeout-minutes: 20
# Outputs all changed envs in a json format to start matrix jobs
outputs:
matrix: ${{ steps.get-dir-names.outputs.dir_names }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Only check for changed files if it's not a change to the Dockerfile or the docker-build workflow
# Changed to Dockerfile or docker-build-workflow will trigger builds for every environment.
- name: Check changed files
id: changed-files
uses: tj-actions/changed-files@v34
with:
files: |
configurations/*/portal/**
dir_names: true
json: true
- name: Get dir names
id: get-dir-names
uses: actions/github-script@v6
with:
script: |
const folders = JSON.parse("${{ steps.changed-files.outputs.all_changed_files }}");
const newArr = [];
for (let folder of folders) {
const folderNameParts = folder.split('/');
const folderName = `${folderNameParts[1]}`
if (!newArr.includes(folderName)) {
newArr.push(folderName)
}
}
core.setOutput('dir_names', JSON.newArr)
matrix-builder-job:
name: ${{ matrix.environments }} - gen3 data portal build
timeout-minutes: 20
runs-on: ubuntu-latest
needs: [get-changes-for-envs]
if: ${{ needs.get-changes-for-envs.outputs.matrix != '[]' && needs.get-changes-for-envs.outputs.matrix != '' }}
strategy:
matrix:
environments: ${{ fromJSON(needs.get-changes-for-envs.outputs.matrix) }}
max-parallel: 10
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set branch for data-portal code Checkout
id: branch
run: |
branch="master"
[ -f configurations/${{ matrix.environments }}/portal-branch ] && branch=$(cat configurations/$i/portal-branch)
echo "branch=${branch}" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
repository: uc-cdis/data-portal
path: "./data-portal"
ref: ${{ steps.branch.outputs.branch }}