-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (172 loc) · 5.68 KB
/
build_and_push.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Build and Push Images
on:
pull_request:
branches:
- develop
- main
- master
types:
- opened
- reopened
- synchronize
- closed
inputs:
name:
description: The image name
required: true
type: string
tags:
description: The image tags
required: true
type: string
jobs:
build-artifacts:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Get current date
id: date
run: echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Run build
env:
PUBLIC_URL: '/'
REACT_APP_AUTH_SERIVCE_URL: 'https://ci-europa.kbase.us/services/auth'
run: npm install && npm run build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
# note that the calling workflow must set `secrets: inherit`
username: '${{ secrets.GHCR_USERNAME }}'
password: '${{ secrets.GHCR_TOKEN }}'
- name: Create github action tags from image tags
id: tags
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const tags = '${{ inputs.tags }}'.split(',');
const username = '${{ github.event.repository.owner.login }}';
const repoName = '${{ inputs.name }}';
return tags.map((tag) => {
return `ghcr.io/kbase/static-ui:latest`;
}).join(',');
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
pull: true
push: true
build-args: |
BUILD_DATE=${{ steps.date.outputs.date }}
VCS_REF=${{ github.sha }}
BRANCH='${{ github.ref }}'
TAG='${{ github.ref }}'
tags: '${{ steps.tags.outputs.result }}'
### Cruft
#
# - name: Upload Artifact
# uses: actions/upload-artifact@v3
# with:
# name: static-ui-build
# path: build/
# build-develop-open:
# if: github.base_ref == 'develop' && github.event.pull_request.merged == false
# runs-on: ubuntu-latest
# needs: build-artifacts
# steps:
# - name: Download Artifact
# uses: actions/download-artifact@v3
# with:
# name: static-ui-build
# path: build
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Show build directory contents
# run: |
# ls -la ./
# - name: Show parent directory contents
# run: |
# ls -la ../
# - name: Build without push
# uses: docker/build-push-action@v2
# with:
# context: .
# dockerfile: ./Dockerfile # Specify the path to your Dockerfile
# push: false
# build-develop-merge:
# if: github.base_ref == 'develop' && github.event.pull_request.merged == true
# runs-on: ubuntu-latest
# needs: build-artifacts
# steps:
# - name: Download Artifact
# uses: actions/download-artifact@v3
# with:
# name: static-ui-build
# path: build
# - name: Get current date
# id: date
# run: echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1
# - name: Login to GHCR
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# # note that the calling workflow must set `secrets: inherit`
# username: '${{ secrets.GHCR_USERNAME }}'
# password: '${{ secrets.GHCR_TOKEN }}'
# - name: Create github action tags from image tags
# id: tags
# uses: actions/github-script@v6
# with:
# result-encoding: string
# script: |
# const tags = '${{ inputs.tags }}'.split(',');
# const username = '${{ github.event.repository.owner.login }}';
# const repoName = '${{ inputs.name }}';
# return tags.map((tag) => {
# return `ghcr.io/${username}/${repoName}:${tag}`;
# }).join(',');
# - name: Build and push
# uses: docker/build-push-action@v3
# with:
# context: .
# file: ./Dockerfile
# pull: true
# push: true
# build-args: |
# BUILD_DATE=${{ steps.date.outputs.date }}
# VCS_REF=${{ github.sha }}
# BRANCH='${{ github.ref }}'
# TAG='${{ github.ref }}'
# tags: '${{ steps.tags.outputs.result }}'
#
#
#
# build-main-open:
# if: (github.base_ref == 'main' || github.base_ref == 'master') && github.event.pull_request.merged == false
# uses: kbase/.github/.github/workflows/reusable_build-push.yml@main
# with:
# name: '${{ github.event.repository.name }}'
# tags: pr-${{ github.event.number }}
# secrets: inherit
# build-main-merge:
# if: (github.base_ref == 'main' || github.base_ref == 'master') && github.event.pull_request.merged == true
# uses: kbase/.github/.github/workflows/reusable_build-push.yml@main
# with:
# name: '${{ github.event.repository.name }}'
# tags: pr-${{ github.event.number }},latest-rc
# secrets: inherit
# trivy-scans:
# if: (github.base_ref == 'develop' || github.base_ref == 'main' || github.base_ref == 'master' ) && github.event.pull_request.merged == false
# uses: kbase/.github/.github/workflows/reusable_trivy-scans.yml@main
# secrets: inherit