-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathaction.yml
More file actions
120 lines (106 loc) · 4.22 KB
/
Copy pathaction.yml
File metadata and controls
120 lines (106 loc) · 4.22 KB
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
name: Compile Modpack
description: Compiles the Star Technology modpack into a distributable zip file
inputs:
branch_name:
description: Branch name used for naming the output artifact
required: true
discord_webhook_url:
description: Discord webhook URL for sending build notifications
required: false
runs:
using: composite
steps:
- name: Create compilation directory
shell: bash
run: mkdir -p compile_output
- name: Create overrides directory structure
shell: bash
run: |
mkdir -p compile_output/overrides
# Copy specified folders to overrides
cp -r config compile_output/overrides/
cp -r defaultconfigs compile_output/overrides/
cp -r kubejs compile_output/overrides/
# Copy specified files to overrides
cp LICENSE compile_output/overrides/
cp README.md compile_output/overrides/
- name: Copy manifest and modlist from compile_data
shell: bash
run: |
cp compile_data/manifest.json compile_output/
cp compile_data/modlist.html compile_output/
- name: Create zip file
shell: bash
run: |
cd compile_output
zip -r "../Star Technology-1.20.1-${{ inputs.branch_name }}.zip" .
cd ..
- name: Upload compiled modpack
uses: actions/upload-artifact@v4
with:
name: Star Technology-1.20.1-${{ inputs.branch_name }}
path: Star Technology-1.20.1-${{ inputs.branch_name }}.zip
retention-days: 30
- name: Send Discord notification
shell: bash
env:
DISCORD_WEBHOOK_URL: ${{ inputs.discord_webhook_url }}
run: |
# Only send notification if webhook URL is provided
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
echo "⚠️ Discord webhook URL not provided, skipping notification"
exit 0
fi
# Calculate expiry date (retention-days from now)
EXPIRY_DATE=$(date -u -d "+30 days" "+%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -v+30d "+%Y-%m-%dT%H:%M:%SZ")
EXPIRY_UNIX=$(date -u -d "+30 days" "+%s" 2>/dev/null || date -u -v+30d "+%s")
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
ARTIFACT_NAME="Star Technology-1.20.1-${{ inputs.branch_name }}"
RESPONSE=$(curl -s -X POST "$DISCORD_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d "{
\"embeds\": [{
\"title\": \"✅ Build Ready: ${ARTIFACT_NAME}\",
\"description\": \"A new build has been compiled and uploaded.\",
\"color\": 5763719,
\"fields\": [
{
\"name\": \"📦 Download Artifact\",
\"value\": \"[View on GitHub Actions](${RUN_URL})\",
\"inline\": false
},
{
\"name\": \"⏳ Expires\",
\"value\": \"<t:${EXPIRY_UNIX}:F> (<t:${EXPIRY_UNIX}:R>)\",
\"inline\": false
},
{
\"name\": \"🌿 Branch\",
\"value\": \"\`${{ inputs.branch_name }}\`\",
\"inline\": true
},
{
\"name\": \"🔁 Run\",
\"value\": \"[#${{ github.run_number }}](${RUN_URL})\",
\"inline\": true
}
],
\"timestamp\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"
}]
}" -w "\n%{http_code}")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
if [ "$HTTP_CODE" = "204" ]; then
echo "✅ Discord notification sent successfully"
else
echo "❌ Failed to send Discord notification (HTTP $HTTP_CODE)"
echo "Response: $(echo "$RESPONSE" | head -n-1)"
exit 1
fi
- name: Display compilation info
shell: bash
run: |
echo "✅ Modpack compiled successfully!"
echo "📦 Artifact name: Star Technology-1.20.1-${{ inputs.branch_name }}"
echo "🏷️ Branch: ${{ inputs.branch_name }}"
echo "📁 Zip file: Star Technology-1.20.1-${{ inputs.branch_name }}.zip"
ls -la "Star Technology-1.20.1-${{ inputs.branch_name }}.zip"