-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (126 loc) · 4.23 KB
/
ci.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
name: CI
on: # Trigger the workflow on push to main, pull request to main, or manual trigger
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
reserve-ci-instance: # Reserve an instance
runs-on: ubuntu-latest
container: alpine:3.20
outputs:
mpkit-url: ${{ steps.reserve.outputs.mpkit-url }}
report-path: ${{ steps.reserve.outputs.report-path }}
steps:
- name: Get ci-instance-url
id: reserve
uses: Platform-OS/ci-repository-reserve-instance-url@mask-token
with:
repository-url: ${{ vars.CI_REPOSITORY_URL }}
method: reserve
pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
deploy:
needs: ["reserve-ci-instance"] # Don't run this job until the reserve-ci-instance job is done
runs-on: ubuntu-latest
container: platformos/playwright:5.1.5-1.47.2
env:
MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }}
MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }}
POS_CI_REPO_ACCESS_TOKEN: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
CI: true
steps:
- name: get-mpkit-token
id: get-token
uses: Platform-OS/ci-repository-reserve-instance-url@mask-token
with:
method: get-token
repository-url: ${{ vars.CI_REPOSITORY_URL }}
pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
- name: use mpkit-token
env:
TOKEN: "${{ steps.get-token.outputs.mpkit-token }}"
run: |
echo hide-token
echo "${{ env.TOKEN }}"
- name: Checkout your repository
uses: actions/checkout@v4
- name: Install pos-cli
shell: sh
run: |
set -eu
npm install -g @platformos/pos-cli
- name: Deploy your project to the reserved instance
env:
MPKIT_TOKEN: ${{ steps.get-token.outputs.mpkit-token }}
shell: sh
run: |
set -eu
mkdir -p /tmp/allow-data-clean/app
cp app/config.yml /tmp/allow-data-clean/app
cd /tmp/allow-data-clean
echo 'allow_data_clean: true' >> app/config.yml
pos-cli deploy -p
cd -
rm -rf /tmp/allow-data-clean
export CONFIRMATION_TEXT=$(echo "$MPKIT_URL" | sed 's|https://||')
pos-cli data clean --auto-confirm --include-schema
pos-cli deploy
tests:
needs: ["reserve-ci-instance", "deploy"] # Don't run this job until both the reserve-ci-instance and deploy jobs are done
runs-on: ubuntu-latest
container: platformos/playwright:5.1.5-1.47.2
env:
MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }}
MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }}
REPORT_PATH: ${{ needs.reserve-ci-instance.outputs.report-path }}
UPLOAD_HOST: ${{ vars.TEST_REPORTS_UPLOAD_HOST }}
CI: true
steps:
- name: Checkout your repository
uses: actions/checkout@v4
- name: Run unit tests
shell: sh
run: |
set -eu
npm run ci:test:unit
cleanup:
if: ${{ always() }}
needs: ["reserve-ci-instance", "deploy", "tests"]
runs-on: ubuntu-latest
container: alpine:3.20
steps:
- name: release ci-instance-url
uses: Platform-OS/ci-repository-reserve-instance-url@mask-token
with:
method: release
repository-url: ${{ vars.CI_REPOSITORY_URL }}
pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
# deploy-qa: # Deploy to QA on push to master and after tests pass
# if: ${{ github.ref_name == 'master' }}
# needs: ["tests"] # Don't run this job until the tests job is done and successful
# runs-on: ubuntu-latest
# env:
# MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }}
# MPKIT_TOKEN: ${{ secrets.MPKIT_TOKEN }}
# MPKIT_URL: ${{ QA-HOST-URL }}
# POS_CI_REPO_ACCESS_TOKEN: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
# CI: true
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
#
# - name: Build
# shell: sh
# run: |
# set -eu
# npm ci
# npm run build
#
# - name: Deploy
# shell: sh
# run: |
# set -eu
# pos-cli deploy