|
| 1 | +name: Compile Modpack |
| 2 | +description: Compiles the Star Technology modpack into a distributable zip file |
| 3 | + |
| 4 | +inputs: |
| 5 | + branch_name: |
| 6 | + description: Branch name used for naming the output artifact |
| 7 | + required: true |
| 8 | + discord_webhook_url: |
| 9 | + description: Discord webhook URL for sending build notifications |
| 10 | + required: false |
| 11 | + |
| 12 | +runs: |
| 13 | + using: composite |
| 14 | + steps: |
| 15 | + - name: Create compilation directory |
| 16 | + shell: bash |
| 17 | + run: mkdir -p compile_output |
| 18 | + |
| 19 | + - name: Create overrides directory structure |
| 20 | + shell: bash |
| 21 | + run: | |
| 22 | + mkdir -p compile_output/overrides |
| 23 | +
|
| 24 | + # Copy specified folders to overrides |
| 25 | + cp -r config compile_output/overrides/ |
| 26 | + cp -r defaultconfigs compile_output/overrides/ |
| 27 | + cp -r kubejs compile_output/overrides/ |
| 28 | + cp -r scripts compile_output/overrides/ |
| 29 | +
|
| 30 | + # Copy specified files to overrides |
| 31 | + cp LICENSE compile_output/overrides/ |
| 32 | + cp README.md compile_output/overrides/ |
| 33 | +
|
| 34 | + - name: Copy manifest and modlist from compile_data |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + cp compile_data/manifest.json compile_output/ |
| 38 | + cp compile_data/modlist.html compile_output/ |
| 39 | +
|
| 40 | + - name: Create zip file |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + cd compile_output |
| 44 | + zip -r "../Star Technology-1.20.1-${{ inputs.branch_name }}.zip" . |
| 45 | + cd .. |
| 46 | +
|
| 47 | + - name: Upload compiled modpack |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + with: |
| 50 | + name: Star Technology-1.20.1-${{ inputs.branch_name }} |
| 51 | + path: Star Technology-1.20.1-${{ inputs.branch_name }}.zip |
| 52 | + retention-days: 30 |
| 53 | + |
| 54 | + - name: Send Discord notification |
| 55 | + shell: bash |
| 56 | + env: |
| 57 | + DISCORD_WEBHOOK_URL: ${{ inputs.discord_webhook_url }} |
| 58 | + run: | |
| 59 | + # Only send notification if webhook URL is provided |
| 60 | + if [ -z "$DISCORD_WEBHOOK_URL" ]; then |
| 61 | + echo "⚠️ Discord webhook URL not provided, skipping notification" |
| 62 | + exit 0 |
| 63 | + fi |
| 64 | +
|
| 65 | + # Calculate expiry date (retention-days from now) |
| 66 | + 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") |
| 67 | + EXPIRY_UNIX=$(date -u -d "+30 days" "+%s" 2>/dev/null || date -u -v+30d "+%s") |
| 68 | + |
| 69 | + RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 70 | + ARTIFACT_NAME="Star Technology-1.20.1-${{ inputs.branch_name }}" |
| 71 | +
|
| 72 | + RESPONSE=$(curl -s -X POST "$DISCORD_WEBHOOK_URL" \ |
| 73 | + -H "Content-Type: application/json" \ |
| 74 | + -d "{ |
| 75 | + \"embeds\": [{ |
| 76 | + \"title\": \"✅ Build Ready: ${ARTIFACT_NAME}\", |
| 77 | + \"description\": \"A new build has been compiled and uploaded.\", |
| 78 | + \"color\": 5763719, |
| 79 | + \"fields\": [ |
| 80 | + { |
| 81 | + \"name\": \"📦 Download Artifact\", |
| 82 | + \"value\": \"[View on GitHub Actions](${RUN_URL})\", |
| 83 | + \"inline\": false |
| 84 | + }, |
| 85 | + { |
| 86 | + \"name\": \"⏳ Expires\", |
| 87 | + \"value\": \"<t:${EXPIRY_UNIX}:F> (<t:${EXPIRY_UNIX}:R>)\", |
| 88 | + \"inline\": false |
| 89 | + }, |
| 90 | + { |
| 91 | + \"name\": \"🌿 Branch\", |
| 92 | + \"value\": \"\`${{ inputs.branch_name }}\`\", |
| 93 | + \"inline\": true |
| 94 | + }, |
| 95 | + { |
| 96 | + \"name\": \"🔁 Run\", |
| 97 | + \"value\": \"[#${{ github.run_number }}](${RUN_URL})\", |
| 98 | + \"inline\": true |
| 99 | + } |
| 100 | + ], |
| 101 | + \"timestamp\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\" |
| 102 | + }] |
| 103 | + }" -w "\n%{http_code}") |
| 104 | + |
| 105 | + HTTP_CODE=$(echo "$RESPONSE" | tail -n1) |
| 106 | + if [ "$HTTP_CODE" = "204" ]; then |
| 107 | + echo "✅ Discord notification sent successfully" |
| 108 | + else |
| 109 | + echo "❌ Failed to send Discord notification (HTTP $HTTP_CODE)" |
| 110 | + echo "Response: $(echo "$RESPONSE" | head -n-1)" |
| 111 | + exit 1 |
| 112 | + fi |
| 113 | +
|
| 114 | + - name: Display compilation info |
| 115 | + shell: bash |
| 116 | + run: | |
| 117 | + echo "✅ Modpack compiled successfully!" |
| 118 | + echo "📦 Artifact name: Star Technology-1.20.1-${{ inputs.branch_name }}" |
| 119 | + echo "🏷️ Branch: ${{ inputs.branch_name }}" |
| 120 | + echo "📁 Zip file: Star Technology-1.20.1-${{ inputs.branch_name }}.zip" |
| 121 | + ls -la "Star Technology-1.20.1-${{ inputs.branch_name }}.zip" |
0 commit comments