-
Notifications
You must be signed in to change notification settings - Fork 2
143 lines (124 loc) · 4.97 KB
/
xquare-deployment-prod.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: Xquare Deploy for Production
on:
push:
branches:
- main
paths:
- "services/**"
env:
SERVICE_TYPE: fe
jobs:
get-versioning:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
outputs:
type: ${{ steps.versioning.outputs.type }}
steps:
- name: Check Out The Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GHP_TOKEN }}
- name: Get Prefix By Commit
id: get_commit_prefix
run: echo $(echo "${{ github.event.head_commit.message }}" | cut -d ":" -f 1 | cut -d "(" -f 1 | cut -d " " -f 1)
- name: Parse xquare-versioning.json
id: parse_xquare_versioning
run: |
content=`cat ./xquare-versioning.json`
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "::set-output name=xquareVersioning::$content"
- name: Get Do Versioning
id: versioning
run: |
echo "::set-output name=type::${{ fromJson(steps.parse_xquare_versioning.outputs.xquareVersioning).commit.fix }}"
get-diff-workspace:
needs: get-versioning
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check Out The Repository
uses: actions/checkout@v3
with:
fetch-depth: '2'
token: ${{ secrets.GHP_TOKEN }}
- name: diff-workspace
id: set-matrix
run: echo "::set-output name=matrix::{\"workspaces\":[$(yarn changed list --git-range $(git rev-parse HEAD^) --json --exclude xquare-frontend --exclude @shared/xbridge | tr "\n" ",")]}"
build:
permissions:
id-token: write
contents: read
name: Build
needs: [get-diff-workspace, get-versioning]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.get-diff-workspace.outputs.matrix) }}
steps:
- name: Check Out The Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GHP_TOKEN }}
- name: Get Service
id: get_service
run: echo ::set-output name=SERVICE::$(echo ${{ matrix.workspaces.name }} | cut -d / -f 2)
- name: Get access key
id: access_key
run: |
service_name="${{steps.get_service.outputs.SERVICE}}"
if [[ $service_name == "apply" ]]; then
echo "ACCESS_KEY=${{ secrets.APPLY_ACCESS_KEY }}" >> $GITHUB_OUTPUT
elif [[ $service_name == "dormitory-admin" ]]; then
echo "ACCESS_KEY=${{ secrets.DOMITORY_ACCESS_KEY }}" >> $GITHUB_OUTPUT
elif [[ $service_name == "feed" ]]; then
echo "ACCESS_KEY=${{ secrets.FEED_ACCESS_KEY }}" >> $GITHUB_OUTPUT
elif [[ $service_name == "school-meal" ]]; then
echo "ACCESS_KEY=${{ secrets.MEAL_ACCESS_KEY }}" >> $GITHUB_OUTPUT
elif [[ $service_name == "xbridge-test" ]]; then
echo "ACCESS_KEY=${{ secrets.XBRIDGE_TEST_ACCESS_KEY }}" >> $GITHUB_OUTPUT
fi
- name: Deploy to xquare
uses: team-xquare/xquare-deployment-action@master
with:
environment: prod
access_key: ${{ steps.access_key.outputs.ACCESS_KEY }}
github_token: ${{ secrets.GHP_TOKEN }}
base_url: services/${{ steps.get_service.outputs.SERVICE }}
config_file_path: services/${{ steps.get_service.outputs.SERVICE }}/.xquare/config.yaml
yarn_docker_build: true
yarn_workspace: "@service/${{ steps.get_service.outputs.SERVICE }}"
commit_version:
name: Commit version
needs: [get-diff-workspace, get-versioning]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.get-diff-workspace.outputs.matrix) }}
steps:
- name: Check Out The Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GHP_TOKEN }}
- name: Get Service
id: get_service
run: echo ::set-output name=SERVICE::$(echo ${{ matrix.workspaces.name }} | cut -d / -f 2)
- name: Sync Package Version
run: yarn workspace @service/${{ steps.get_service.outputs.SERVICE }} version ${{ needs.get-versioning.outputs.type }}
- name: Get Package Version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: ${{ matrix.workspaces.location }}
- name: Pull Commit
run: git pull
- name: Commit With Versioning
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "release(${{steps.get_service.outputs.SERVICE}}): ${{ steps.package-version.outputs.current-version }} [skip ci]"
branch: main
commit_options: '--no-verify --signoff'
repository: .
commit_user_name: XQUARE Frontend Bot
commit_user_email: [email protected]
commit_author: XQUARE Frontend Bot <[email protected]>