-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (96 loc) · 3.3 KB
/
portal-docker-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
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
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on:
push:
branches:
- master
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.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: changed-files
uses: tj-actions/changed-files@v34
with:
files: |
*/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[0]}`
if (!newArr.includes(folderName)) {
newArr.push(folderName)
}
}
core.setOutput('dir_names', JSON.stringify(JSON.stringify(newArr)))
- id: set-matrix
run: echo "matrix={\"environments\":${{ steps.get-dir-names.outputs.dir_names }}}" >> "$GITHUB_OUTPUT"
matrix-builder-job:
name: ${{ matrix.environments }} - gen3 data portal build
timeout-minutes: 20
runs-on: ubuntu-latest
needs: [get-changes-for-envs]
strategy:
matrix: ${{ fromJSON(needs.get-changes-for-envs.outputs.matrix) }}
max-parallel: 10
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v3
# TODO: Build webpack outside of docker so you can push bundles to s3
# - name: Checkout
# uses: actions/checkout@v3
# with:
# ref: feat/jq_prebuilder
# fetch-depth: 1
# repository: uc-cdis/data-portal
# path: './data-portal'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# https://github.com/docker/login-action#quayio
- name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Set Versions
uses: actions/github-script@v6
id: set_version
with:
script: |
const rawtag = "${{ matrix.environments }}"
const tag = rawtag.replace('.', '_')
console.log(tag)
core.setOutput('tag', tag)
- name: Build and push
uses: docker/build-push-action@v3
env:
TAG: ${{ matrix.environments }}-${{ steps.date.outputs.date }}
LATEST: ${{ matrix.environments }}-latest
with:
build-args: |
PORTAL_HOSTNAME=${{ matrix.environments }}
context: .
push: true
tags: quay.io/cdis/data-portal-prebuilt:${{ env.TAG }}, quay.io/cdis/data-portal-prebuilt:${{ env.LATEST }}