This repository has been archived by the owner on May 28, 2024. It is now read-only.
generated from CrimsonWarpedcraft/plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (82 loc) · 2.86 KB
/
snapshot.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
name: Build Snapshot
on:
push:
branches:
- 'main'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
java: [ 11, 16 ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
- name: Grant execute permission for gradlew
if: runner.os == 'Linux'
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build --info
- name: Upload build results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }} Java ${{ matrix.java }} build results
path: ${{ github.workspace }}/build/
artifact:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'zulu'
- name: Grant execute permission for gradlew
if: runner.os == 'Linux'
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build --info
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: Snapshot Jar(s)
path: ${{ github.workspace }}/build/libs/
notify:
needs: artifact
runs-on: ubuntu-latest
env:
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }}
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
if: ${{ always() }}
steps:
- name: Notify on success
if: ${{ env.DISCORD_WEBHOOK_ID != null && env.DISCORD_WEBHOOK_TOKEN != null && needs.artifact.result == 'success' }}
uses: appleboy/discord-action@0.0.3
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#00FF00"
username: "CW Build Status Bot"
message: >
${{ github.repository }} build ${{ github.run_number }} successfully completed:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Notify on failure
if: ${{ env.DISCORD_WEBHOOK_ID != null && env.DISCORD_WEBHOOK_TOKEN != null && (needs.build.result == 'failure' || needs.artifact.result == 'failure') }}
uses: appleboy/discord-action@0.0.3
with:
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#FF0000"
username: "CW Build Status Bot"
message: >
${{ github.repository }} build ${{ github.run_number }} failed:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}