forked from The-Aether-Team/The-Aether
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontinue_config.yml
170 lines (161 loc) · 6.85 KB
/
continue_config.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
version: 2.1
orbs:
gradle: circleci/gradle@3.0.0
parameters:
artifact-name:
type: string
default: aether-1.20.1-1.0.0-neoforge.jar
deploy-branch:
type: string
default: 1.20.1-develop
allow-deploy-and-discord-publish:
type: boolean
default: false
jobs:
build:
machine:
image: ubuntu-2204:2023.02.1
resource_class: large
environment:
_JAVA_OPTIONS: -Xmx9600m
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.logging.level=info
steps:
- setup
- run:
name: Remove unnecssary jars before persist
command: |
cd ~/project/build/libs
find . ! -name << pipeline.parameters.artifact-name >> -type f -exec rm -f {} +
- persist_to_workspace:
root: ~/project/build/libs
paths:
- << pipeline.parameters.artifact-name >>
- run:
name: Publish artifact link to Discord
command: |
if [ ${CIRCLE_BRANCH} = << pipeline.parameters.deploy-branch >> ] && << pipeline.parameters.allow-deploy-and-discord-publish >>; then
artifact_path=$(curl --request GET --url https://circleci.com/api/v2/project/gh/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/$CIRCLE_BUILD_NUM/artifacts -H "Accept: application/json" | jq -r '.items[2].path')
if [ -z "${WEBHOOK_URL}" ]; then
echo "NO DISCORD WEBHOOK SET"
echo "Please input your DISCORD_WEBHOOK value either in the settings for this project, or as a parameter for this orb."
exit 1
else
curl -X POST -H 'Content-type: application/json' \
--data \
"{ \
\"embeds\": [{ \
\"title\": \"$CIRCLE_BRANCH\", \
\"description\": \"The latest CircleCI job has completed, a direct download link for the build can be found here: https://output.circle-artifacts.com/output/job/${CIRCLE_WORKFLOW_JOB_ID}/artifacts/${CIRCLE_NODE_INDEX}/${artifact_path}\", \
\"color\": \"301898\", \
\"fields\": [ \
{ \
\"name\": \"Project\", \
\"value\": \"$CIRCLE_PROJECT_REPONAME\", \
\"inline\": true \
}, \
{ \
\"name\": \"Job Number\", \
\"value\": \"$CIRCLE_BUILD_NUM\", \
\"inline\": true \
} \
] \
}] \
}" ${WEBHOOK_URL}
fi
fi
deploy:
machine: true
resource_class: the-aether-team/ants-deploy
steps:
- when:
condition: <<pipeline.parameters.allow-deploy-and-discord-publish>>
steps:
- attach_workspace:
at: ~/project/build/libs
- run:
name: Remove unnecssary jars before deploy
command: |
cd ~/project/build/libs
find . ! -name << pipeline.parameters.artifact-name >> -type f -exec rm -f {} +
- store_artifacts:
path: ~/project/build/libs
- run:
name: Reinstall and start server
command: |
UPDATE_RESPONSE=$(curl -X PUT -s -o /dev/null -w "%{http_code}" "${DEPLOY_LOCATION}/api/client/servers/${SERVER_ID}/startup/variable" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${USER_KEY}" \
-d '{ "key": "ARTIFACT_BUILD_NUM", "value": "'"${CIRCLE_BUILD_NUM}"'" }')
if [[ $UPDATE_RESPONSE == 200 ]]; then
echo "Updated server environment variable 'ARTIFACT_BUILD_NUM' with ${CIRCLE_BUILD_NUM}"
else
echo "Error updating environment: ${UPDATE_RESPONSE}"
exit 1
fi
REINSTALL_RESPONSE=$(curl -s -o /dev/null -I -X POST -w "%{http_code}" \
"${DEPLOY_LOCATION}/api/client/servers/${SERVER_ID}/settings/reinstall" \
-H "Authorization: Bearer ${USER_KEY}")
if (( $REINSTALL_RESPONSE >= 200 )); then
echo "Server received reinstallation request."
if (( $REINSTALL_RESPONSE == 204 )); then
while [[ ! $(curl -s "${DEPLOY_LOCATION}/api/client/servers/${SERVER_ID}" \
-H "Authorization: Bearer ${USER_KEY}" | jq '.attributes | .is_installing') ]];
do
echo "Waiting for installation to begin..."
sleep 2
done
fi
echo "Server reinstallation has started."
while [[ $(curl -s "${DEPLOY_LOCATION}/api/client/servers/${SERVER_ID}" \
-H "Authorization: Bearer ${USER_KEY}" | jq '.attributes | .is_installing') == true ]];
do
echo "Waiting for installation..."
sleep 10
done
echo "Sending start signal to server."
START_RESPONSE=$(curl -X POST -s -o /dev/null -w "%{http_code}" "${DEPLOY_LOCATION}/api/client/servers/${SERVER_ID}/power" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${USER_KEY}" \
-d '{ "signal": "start" }')
if (( $START_RESPONSE == 204 )); then
echo "Server received start signal."
else
echo "Server start unsucessful. Response: ${START_RESPONSE}"
exit 1
fi
else
echo "Received ${REINSTALL_RESPONSE}: Reinstall unsucessful."
exit 1
fi
- unless:
condition: <<pipeline.parameters.allow-deploy-and-discord-publish>>
steps:
- run: echo "Condition not met."
commands:
setup:
steps:
- checkout
- gradle/with_cache:
cache_key: 'v9'
steps:
- run:
name: chmod permissions
command: chmod +x ./gradlew
- run: ./gradlew build --parallel --console=plain
- store_artifacts:
path: ~/project/build/libs
workflows:
build-and-deploy:
jobs:
- build
- deploy:
context:
- vpn
filters:
branches:
only:
- << pipeline.parameters.deploy-branch >>
requires:
- build