Skip to content

README rewrite --skip #607

README rewrite --skip

README rewrite --skip #607

Workflow file for this run

name: Build
on:
workflow_dispatch:
pull_request:
push:
branches: '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- uses: actions/setup-java@v3.6.0
with:
distribution: temurin
java-version: 21
cache: 'gradle'
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install dependencies
run: npm install dayjs
- name: Generate JSON Payload
run: |
COMMIT_HASH=$(git rev-parse HEAD | cut -c1-6)
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
BUILD_TYPE="Build Started"
TIMESTAMP=$(date --utc +%Y-%m-%dT%H:%M:%SZ)
COLOR=14396170
if [[ "$COMMIT_MESSAGE" == *"--skip"* ]]; then
COLOR=12596459
BUILD_TYPE="Silent Update Started"
fi
cat <<EOF > push.json
{
"username": "GitHub Actions",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"embeds": [
{
"title": "$BUILD_TYPE",
"url": "https://github.com/CraftCanvasMC/Canvas/",
"color": $COLOR,
"fields": [
{
"name": "Version",
"value": "MC1.21.1-$COMMIT_HASH",
"inline": false
},
{
"name": "Build Branch",
"value": "master",
"inline": false
},
{
"name": "Commit message",
"value": "$COMMIT_MESSAGE",
"inline": false
}
],
"author": {
"name": "Canvas",
"url": "https://github.com/CraftCanvasMC/Canvas",
"icon_url": "https://cdn.discordapp.com/icons/1168986665038127205/5acce10798a8cddde4bb25638076f0b3.webp?"
},
"timestamp": "$TIMESTAMP",
"footer": {
"text": "Dueris",
"icon_url": "https://cdn.discordapp.com/avatars/1001318720922210394/0a5b3901bd3d4be7b8b7014f52927ffa.webp?"
}
}
]
}
EOF
- name: Send Discord Notification
uses: tsickert/discord-webhook@v5.3.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
raw-data: push.json
- name: Run Deploy
if: "!contains(github.event.head_commit.message, '--skip') && !contains(github.event.head_commit.commit.message, '--skip')"
run: |
git config --global user.email "no-reply@github.com" && git config --global user.name "Github Actions"
./gradlew applyPatches --no-daemon
./gradlew createCanvasServer --no-daemon
./gradlew generateDevelopmentBundle --info
- name: Rebuild on Failure
if: ${{ failure() }}
run: |
./gradlew clean cleanCache
./gradlew applyPatches --no-daemon
./gradlew createCanvasServer --no-daemon
./gradlew generateDevelopmentBundle --no-daemon
- name: Prep Release
if: "!contains(github.event.head_commit.message, '--skip') && !contains(github.event.head_commit.commit.message, '--skip')"
run: echo "COMMIT_HASH=$(git log --format='%H' -n 1)" >> $GITHUB_ENV
id: set_commit_hash
- name: Create Release Data
if: "!contains(github.event.head_commit.message, '--skip') && !contains(github.event.head_commit.commit.message, '--skip')"
uses: softprops/action-gh-release@v1
with:
name: Build ${{ github.run_number }}
tag_name: ${{ github.run_number }}
body: "[\"artifact_name\"=canvas-launcher.jar]/[\"changes\"=${{ github.event.head_commit.message }}]/[\"commit_hash\"=${{ env.COMMIT_HASH }}]/[\"version\"=MC1.21.1]"
token: ${{ secrets.GIT_TOKEN }}
files: target/*.jar
- name: Generate JSON Payload
if: "!contains(github.event.head_commit.message, '--skip') && !contains(github.event.head_commit.commit.message, '--skip')"
run: |
COMMIT_HASH=$(git rev-parse HEAD | cut -c1-6)
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
BUILD_TYPE="Build Successful"
TIMESTAMP=$(date --utc +%Y-%m-%dT%H:%M:%SZ)
COLOR=3534904
cat <<EOF > push.json
{
"username": "GitHub Actions",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"embeds": [
{
"title": "$BUILD_TYPE",
"url": "https://github.com/CraftCanvasMC/Canvas/",
"color": $COLOR,
"fields": [
{
"name": "Version",
"value": "MC1.21.1-$COMMIT_HASH",
"inline": false
},
{
"name": "Build Branch",
"value": "master",
"inline": false
},
{
"name": "Commit message",
"value": "$COMMIT_MESSAGE",
"inline": false
}
],
"author": {
"name": "Canvas",
"url": "https://github.com/CraftCanvasMC/Canvas",
"icon_url": "https://cdn.discordapp.com/icons/1168986665038127205/5acce10798a8cddde4bb25638076f0b3.webp?"
},
"timestamp": "$TIMESTAMP",
"footer": {
"text": "Dueris",
"icon_url": "https://cdn.discordapp.com/avatars/1001318720922210394/0a5b3901bd3d4be7b8b7014f52927ffa.webp?"
}
}
]
}
EOF
- name: Send Discord Notification
uses: tsickert/discord-webhook@v5.3.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
raw-data: push.json