-
Notifications
You must be signed in to change notification settings - Fork 6
118 lines (104 loc) · 3.95 KB
/
main.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
name: Supremo CICD
on:
push:
branches:
- dev-howie
jobs:
build_supremo_app:
env:
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
REACT_APP_CARLIST_URL: http://140.238.204.249/car-service-redis/cars
REACT_APP_CARAPP_LOGINAUTH_URL: http://140.238.204.249/user-service-redis/authn
REACT_APP_GET_USER_BY_ID: http://140.238.204.249/user-service-redis/users/
REACT_APP_CREATE_ORDER_API: http://140.238.204.249/order-service/create-order
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get or create an OCIR Repository
uses: oracle-actions/[email protected]
id: get-ocir-repository
with:
name: frontend/supremo-reactjs-${GITHUB_REPOSITORY_ID}
compartment: ${{ secrets.OCI_COMPARTMENT_OCID }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.get-ocir-repository.outputs.repo_path }}
tags: |
type=sha,prefix=
- name: Login to OCI Container Registry
uses: oracle-actions/[email protected]
id: login-ocir
with:
auth_token: ${{ secrets.OCI_AUTH_TOKEN }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
working-directory: frontend
run: npm list
- name: Install dependencies
working-directory: frontend
run: npm install
- name: Build supremo app
working-directory: frontend
run: CI=false npm run build
- name: Build and push image
id: build
uses: docker/build-push-action@v5
with:
context: frontend/.
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
push: true
deploy_app:
env:
OCI_CLI_USER: ${{ secrets.OCI_CLI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_CLI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_CLI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_CLI_KEY_CONTENT }}
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
runs-on: ubuntu-latest
needs:
- build_supremo_app
steps:
- name: Get or create an OCIR Repository
uses: oracle-actions/[email protected]
id: get-ocir-repository
with:
name: frontend/supremo-reactjs-${GITHUB_REPOSITORY_ID}
compartment: ${{ secrets.OCI_COMPARTMENT_OCID }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.get-ocir-repository.outputs.repo_path }}
tags: |
type=sha,prefix=
- name: Deploy via OCI DevOps Deployment Pipeline
uses: oracle-actions/[email protected]
with:
command: devops deployment create-pipeline-deployment --pipeline-id ${{ secrets.OCI_DEVOPS_PIPELINE_ID }} --deployment-arguments "{\"items\":[{\"name\":\"IMG\",\"value\":\"${{ steps.get-ocir-repository.outputs.repo_path }}:${{ steps.meta.outputs.version }}\"}]}"
silent: true