-
-
Notifications
You must be signed in to change notification settings - Fork 22
145 lines (122 loc) · 4.43 KB
/
nightly-publish.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
name: Nightly Build and Publish
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github
settings-path: ${{ github.workspace }}
- name: Retrieve all commit messages pushed and put in the environment variable GITHUB_COMMITS_TEXT
id: commits
run: |
export commitsText=$(git log --format=%s ${{ github.event.before }}..${{ github.sha }} | tr '\n' ':newline:')
echo "Commits texts: $commitsText"
echo "GITHUB_COMMITS_TEXT=$commitsText" >> $GITHUB_ENV
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_NUMBER: ${{ github.run_number }}
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
uses: gradle/gradle-build-action@v2
with:
arguments: publishAllPublicationsToGitHubPackagesRepository
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_NUMBER: ${{ github.run_number }}
GITHUB_COMMITS_TEXT: ${{ env.GITHUB_COMMITS_TEXT }}
- name: Delete packages, keep most recent
uses: actions/delete-package-versions@v4
with:
package-name: 'org.minefortress.minefortress-nightly'
package-type: 'maven'
min-versions-to-keep: 10
discord-notification:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Send Discord Notification
run: |
messages=$(git log --reverse --format='- %s' ${{ github.event.before }}..${{ github.sha }})
./automation-scripts/discord-notification.sh ${{ secrets.DISCORD_WEBHOOK }} ${{ github.run_number }} "$messages" "${{ vars.DISCORD_ROLE_ID }}"
twitter-notification:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare twitter messages
id: prepare-twitter-messages
run: |
export messages=$(git log --reverse --format='- %s' ${{ github.event.before }}..${{ github.sha }})
echo "Twitter messages: $messages"
echo "twitterMessages=${messages//$'\n'/'\\n'}" >> $GITHUB_OUTPUT
- name: Send Twitter Notification
uses: remmintan/send-tweet-action@1.0
with:
api-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
api-key-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET_KEY }}
access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
tweet-text: |
MineFortress Dev Build ${{ github.run_number }} built successfully!
Changes:
${{ steps.prepare-twitter-messages.outputs.twitterMessages }}
===next-tweet===
Dev Builds portal:
https://builds.minecraftfortress.org
reddit-notification:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare reddit messages
id: prepare-reddit-messages
run: |
export messages=$(git log --reverse --format='- %s' ${{ github.event.before }}..${{ github.sha }})
echo "Reddit messages: $messages"
echo "redditMessages=${messages//$'\n'/'\\n'}" >> $GITHUB_OUTPUT
- name: Send Reddit Notification
uses: remmintan/reddit-post-action@1.0
with:
app-id: ${{ secrets.REDDIT_APP_ID }}
app-secret: ${{ secrets.REDDIT_APP_SECRET }}
username: ${{ secrets.REDDIT_USERNAME }}
password: ${{ secrets.REDDIT_PASSWORD }}
post-title: MineFortress dev build ${{ github.run_number }} built successfully!
post-text: |
Changes:
${{ steps.prepare-reddit-messages.outputs.redditMessages }}
https://builds.minecraftfortress.org