generated from PurpurMC/Tentacles
-
-
Notifications
You must be signed in to change notification settings - Fork 9
178 lines (177 loc) · 6.32 KB
/
dispatch.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
172
173
174
175
176
177
178
name: Dispatch
on:
workflow_dispatch:
push:
branches:
- "master"
jobs:
kill-silent:
runs-on: ubuntu-latest
outputs:
run_rest_jobs: ${{ steps.block.outputs.run_jobs }}
steps:
- uses: actions/checkout@v3
- name: Install dayjs
run: npm install dayjs
- name: Block if Silent
id: block
if: "!contains(github.event.head_commit.message, '--skip')"
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
if [[ "$COMMIT_MESSAGE" == *"--skip"* ]]; then
echo "::set-output name=run_jobs::false"
else
echo "::set-output name=run_jobs::true"
fi
- name: Create Payload
run: |
COMMIT_HASH=$(git rev-parse HEAD | cut -c1-6)
COMMIT_MESSAGE=$(git log -1 --pretty=%B | tr '\n' '_')
BUILD_TYPE="Build Started"
TIMESTAMP=$(date --utc +%Y-%m-%dT%H:%M:%SZ)
COLOR=14396170
if [[ "$COMMIT_MESSAGE" == *"--skip"* ]]; then
COLOR=12596459
BUILD_TYPE="Silent Update"
fi
cat <<EOF > push.json
{
"username": "GitHub Actions",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"embeds": [
{
"title": "$BUILD_TYPE",
"url": "https://github.com/CraftCanvasMC/Canvas/",
"color": $COLOR,
"fields": [
{
"name": "Version",
"value": "MC1.21.4-$COMMIT_HASH",
"inline": false
},
{
"name": "Build Branch",
"value": "master",
"inline": false
},
{
"name": "Commit message",
"value": "$COMMIT_MESSAGE",
"inline": false
}
],
"author": {
"name": "Canvas",
"url": "https://github.com/CraftCanvasMC/Canvas",
"icon_url": "https://cdn.discordapp.com/icons/1168986665038127205/5acce10798a8cddde4bb25638076f0b3.webp?"
},
"timestamp": "$TIMESTAMP",
"footer": {
"text": "Dueris",
"icon_url": "https://cdn.discordapp.com/avatars/1001318720922210394/0a5b3901bd3d4be7b8b7014f52927ffa.webp?"
}
}
]
}
EOF
- name: Push Notification Payload
uses: tsickert/[email protected]
if: ${{ github.action_repository == 'CraftCanvasMC/Canvas' || github.repository == 'CraftCanvasMC/Canvas' }}
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
raw-data: push.json
continue-on-error: true
deploy:
needs:
- kill-silent
if: needs.kill-silent.outputs.run_rest_jobs == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
distribution: temurin
java-version: 22
cache: 'gradle'
- name: Setup Node-14
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install dayjs
run: npm install dayjs
- name: Batch and Deploy
run: |
git config --global user.email "[email protected]" && git config --global user.name "Github Actions"
./gradlew applyPatches --no-daemon
./gradlew createCanvasServer --no-daemon
- name: Fallback
if: ${{ failure() }}
run: |
./gradlew clean cleanCache
./gradlew applyPatches --no-daemon
./gradlew createCanvasServer --no-daemon
- name: Prepare Hash
run: echo "COMMIT_HASH=$(git log --format='%H' -n 1)" >> $GITHUB_ENV
id: set_commit_hash
- name: Build Release Data
uses: softprops/action-gh-release@v1
with:
name: Build ${{ github.run_number }}
tag_name: ${{ github.run_number }}
body: "[\"artifact_name\"=canvas-launcher.jar]/[\"changes\"=${{ github.event.head_commit.message }}]/[\"commit_hash\"=${{ env.COMMIT_HASH }}]/[\"version\"=MC1.21.4]"
token: ${{ secrets.GIT_TOKEN }}
files: target/*.jar
- name: Create Payload
run: |
COMMIT_HASH=$(git rev-parse HEAD | cut -c1-6)
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
BUILD_TYPE="Build Successful"
TIMESTAMP=$(date --utc +%Y-%m-%dT%H:%M:%SZ)
COLOR=3534904
cat <<EOF > push.json
{
"username": "GitHub Actions",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"embeds": [
{
"title": "$BUILD_TYPE",
"url": "https://github.com/CraftCanvasMC/Canvas/",
"color": $COLOR,
"fields": [
{
"name": "Version",
"value": "MC1.21.4-$COMMIT_HASH",
"inline": false
},
{
"name": "Build Branch",
"value": "master",
"inline": false
},
{
"name": "Commit message",
"value": "$COMMIT_MESSAGE",
"inline": false
}
],
"author": {
"name": "Canvas",
"url": "https://github.com/CraftCanvasMC/Canvas",
"icon_url": "https://cdn.discordapp.com/icons/1168986665038127205/5acce10798a8cddde4bb25638076f0b3.webp?"
},
"timestamp": "$TIMESTAMP",
"footer": {
"text": "Dueris",
"icon_url": "https://cdn.discordapp.com/avatars/1001318720922210394/0a5b3901bd3d4be7b8b7014f52927ffa.webp?"
}
}
]
}
EOF
- name: Push Notification Payload
if: ${{ github.action_repository == 'CraftCanvasMC/Canvas' || github.repository == 'CraftCanvasMC/Canvas' }}
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
raw-data: push.json
continue-on-error: true