-
Notifications
You must be signed in to change notification settings - Fork 5
143 lines (131 loc) · 4.11 KB
/
_deploy-sandbox.js.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
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
name: '* Build & Deployment (Sandbox-UI)'
run-name: |
${{ github.event.inputs.delete == 'true'
&& 'deleting' || github.event.inputs.run_build == 'true'
&& 'building and deploying Sandbox-UI' || 'deploying Sandbox-UI' }}
${{ github.event.inputs.tag_name }}
${{ github.event.inputs.delete == 'true' && 'from' || 'to' }}
${{ github.event.inputs.deploy_environment }}
on:
workflow_dispatch:
inputs:
deploy_environment:
description: 'target environment'
required: true
default: 'test'
type: choice
options:
- test
- acceptance
- production
tag_name:
description: 'branch or tag to deploy'
default: 'develop'
type: string
run_build:
description: '(re)build docker image'
default: false
type: boolean
delete:
default: false
type: boolean
jobs:
make-env-file-sandbox:
uses: ./.github/workflows/env-file-generation-sandbox.yaml
with:
deploy_environment: ${{ github.event.inputs.deploy_environment }}
secrets: inherit
run-e2e-sandbox:
if: ${{ github.event.inputs.run_build == 'true' }}
name: 'e2e'
uses: ./.github/workflows/run-tests-e2e-sandbox.yaml
run-unit:
if: ${{ github.event.inputs.run_build == 'true' }}
name: 'tests'
uses: ./.github/workflows/run-tests.yaml
secrets: inherit
run-sonar:
if: ${{ github.event.inputs.run_build == 'true' }}
needs: [run-unit]
uses: ./.github/workflows/run-sonar.yaml
secrets: inherit
build-dist:
if: ${{ github.event.inputs.run_build == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_name }}
- name: Build Artifact
uses: actions/setup-node@v4
with:
node-version: '18.18.0'
- run: npm install
- run: npm run build-shared
- run: npm run dist-sandbox
- uses: actions/upload-artifact@master
with:
name: dist
path: ./projects/sandbox/dist
push-docker-image:
needs: [build-dist, run-unit, run-e2e-sandbox]
if: ${{ github.event.inputs.run_build == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_name }}
- name: Get Built Artifact
uses: actions/download-artifact@master
with:
name: dist
path: ./projects/sandbox/dist
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Set up Docker Build
uses: docker/setup-buildx-action@v3
- run: |
tag=${{ github.event.inputs.tag_name || 'develop' }}
TAG_ESCAPED=${tag//[\/]/_}
echo TAG_ESCAPED=${TAG_ESCAPED} >> $GITHUB_ENV
- name: Extract Metadata for Docker Image
id: meta
uses: docker/metadata-action@v5
env:
PROJECT_VERSION: ${{ secrets.PROJECT_VERSION }}
with:
images: europeana/metis-sandbox-ui
tags: |
type=sha
${{ env.TAG_ESCAPED }}
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
${{ env.PROJECT_VERSION }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./projects/sandbox
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push-to-kubernetes:
if: |
always()
&& !contains(needs.*.result, 'failure')
&& !cancelled()
needs: [push-docker-image, make-env-file-sandbox]
uses: ./.github/workflows/deploy-image.yaml
with:
image_name: metis-sandbox-ui
project_dir: sandbox
secrets: inherit