-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (139 loc) Β· 4.93 KB
/
deployment.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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Deployment
on:
workflow_dispatch:
push:
tags:
- 'v*.*.*'
branches:
- next
- main
env:
REGISTRY: ghcr.io
USERNAME: ${{ github.repository_owner }}
NODE_VERSION: v20.0.0
jobs:
build:
name: π Build Container
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: persianpart-pwa
dockerfile: cloud/pwa/Dockerfile
description: Persian Part Company PWA Nginx Server
- name: persianpart-api
dockerfile: cloud/api/Dockerfile
description: Persian Part Company API Server
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: β€΅οΈ Checkout repository
uses: actions/checkout@v4.1.1
- name: π Setup nodejs
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name: π Install dependencies
run: yarn install --immutable
- name: π Build `${{ matrix.name }}` Projects
run: yarn nx run ${{ matrix.name }}:build
- name: π Setup Docker Buildx
uses: docker/setup-buildx-action@v2.9.1
- name: π Log into registry `${{ env.REGISTRY }}`
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v2.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: π Extract metadata
id: meta
uses: docker/metadata-action@v4.6.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: name=${{ env.REGISTRY }}/${{ env.USERNAME }}/deprecate/${{ matrix.name }},enable=true
labels: |
org.opencontainers.image.authors=MM25Zamanian@gmail.com
org.opencontainers.image.title=@gecut/${{ matrix.name }}-deprecate
org.opencontainers.image.description=${{ matrix.description }}
org.opencontainers.image.distribution = "https://github.com/gecut/persianpart"
tags: |
type=semver,enable=true,pattern={{major}}
type=semver,enable=true,pattern={{major}}.{{minor}}
type=semver,enable=true,pattern={{version}}
type=ref,enable=true,event=pr
type=ref,enable=true,event=branch
type=sha,format=long
type=raw,enable={{is_default_branch}},value=latest
- name: π Build and push container image
id: build-and-push
uses: docker/build-push-action@v4.1.1
with:
push: ${{ github.event_name != 'pull_request' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .
file: ${{ matrix.dockerfile }}
build-args: |
APP_NAME=${{ matrix.name }}
PACKAGE_SOURCE=dist/apps/${{ matrix.name }}
cache-from: type=gha
cache-to: type=gha,mode=max
darkube_deploy:
name: π Deploy On Darkube
concurrency: ${{ matrix.name }}-ci-${{ github.ref }}-${{ github.event_name }}
container: hamravesh.hamdocker.ir/public/darkube-cli:v1.1
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: PERSIANPART_PWA
image_tag: latest
- name: PERSIANPART_API
image_tag: latest
steps:
- name: π Deploy [' ${{ matrix.name }} ']
run: darkube deploy --ref master --token ${DARKUBE_DEPLOY_TOKEN} --app-id ${DARKUBE_APP_ID} --image-tag ${{ matrix.image_tag }} --job-id "$GITHUB_RUN_ID" --stateless-app true
env:
DARKUBE_DEPLOY_TOKEN: ${{ secrets[format('{0}__DEPLOY_TOKEN', matrix.name)] }}
DARKUBE_APP_ID: ${{ secrets[format('{0}__APP_ID', matrix.name)] }}
liara_deploy:
name: π Deploy On Lira
needs: build
if: false
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: hami-pwa
source: apps/hami-pwa
- name: hami-orders-site
source: apps/hami-orders-site
- name: hami-api
source: apps/hami-api
steps:
- name: β€΅οΈ Checkout repository
uses: actions/checkout@v4.1.1
- name: π Setup nodejs
uses: actions/setup-node@v4
with:
node-version: 19
- name: π Deploy [' ${{ matrix.name }} ']
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
max_attempts: 10
command: |
cd ${{ matrix.source }}
npx @liara/cli deploy --api-token="${{ secrets.LIARA_API_TOKEN }}" --detach