-
-
Notifications
You must be signed in to change notification settings - Fork 12
executable file
·84 lines (70 loc) · 2.62 KB
/
test-build.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
name: Deployment Test Build
on:
pull_request:
branches: [dev, main, beta]
workflow_call:
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
# This is important to fetch the changes to the previous commit
fetch-depth: 0
- name: Prettify code
uses: creyD/prettier_action@v4.3
with:
prettier_options: '--config .tools/prettier/.prettierrc --ignore-path .tools/prettier/.prettierignore --check . --single-quote --bracket-same-line=true'
dry: true
only_changed: True
test:
runs-on: ubuntu-latest
needs: prettier
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Dependencies
run: npm install
- name: Run Tests
run: npm test
test-deploy:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install test env data
run: |
cp .env.example .env
echo ${{ secrets.TEST_TOKEN }} >> .env
echo ${{ secrets.TEST_TOKEN }} >> .env
echo ${{ secrets.TEST_SECRET }} >> .env
echo ${{ secrets.TEST_APPLICATION_ID }} >> .env
echo ${{ secrets.TEST_DEVELOPER_DISCORD_GUILD_ID }} >> .env
- name: Start Container
run: |
NODE_ENV=production docker compose up -d
- name: Wait 60 seconds and check if all containers are healthy
run: |
sleep 60
docker ps -a
docker inspect --format='{{json .State.Health}}' mittelbot
docker inspect --format='{{json .State.Health}}' mittelbot-mysql
- name: Stop Container
run: |
npm run stop
- name: Stop Workflow
if: steps.check_condition.outputs.stop_workflow == 'true'
run: |
echo "Stopping workflow"
exit 0