-
Notifications
You must be signed in to change notification settings - Fork 3
66 lines (57 loc) · 2.36 KB
/
dev-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
name: Upload Artifacts and Notify Discord
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.5
- name: Build with Gradle
run: gradle clean build --refresh-dependencies
- name: Upload JAR Artifact
id: upload-jar
uses: actions/upload-artifact@v4
with:
name: AuroraLevels-${{ github.run_number }}
path: build/libs/AuroraLevels-**.jar
- name: Get commit messages since last push
id: commits
run: |
echo "Fetching commits between ${{ github.event.before }} and ${{ github.sha }}"
commits_json=$(git log ${{ github.event.before }}..${{ github.sha }} --pretty=format:'{"sha": "%H", "message": "%s"},' | sed '$ s/,$//')
commits_base64=$(echo "[$commits_json]" | base64 -w 0)
echo "commits=$commits_base64" >> $GITHUB_OUTPUT
- name: Upload to server
run: |
commits_json=$(echo "${{ steps.commits.outputs.commits }}" | base64 --decode)
artifact_url="https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${{ steps.upload-jar.outputs.artifact-id }}/zip"
json_payload=$(jq -n \
--arg secret "${{ secrets.SERVER_SECRET }}" \
--arg repo "${{ github.repository }}" \
--arg artifactUrl "$artifact_url" \
--argjson buildNumber ${{ github.run_number }} \
--arg branch "${{ github.ref_name }}" \
--argjson commits "$commits_json" \
'{
secret: $secret,
repo: $repo,
artifact_url: $artifactUrl,
build_number: $buildNumber,
branch: $branch,
commits: $commits
}')
curl -X POST ${{ secrets.SERVER_UPLOAD_URL }} -H "Content-Type: application/json" -d "$json_payload"