Skip to content

Merge pull request #62 from MrMasrozYTLIVE/master #6

Merge pull request #62 from MrMasrozYTLIVE/master

Merge pull request #62 from MrMasrozYTLIVE/master #6

Workflow file for this run

name: Dispatch
on:
workflow_dispatch:
push:
branches:
- "master"
jobs:
kill-silent:
runs-on: ubuntu-latest
outputs:
run_rest_jobs: ${{ steps.block.outputs.run_jobs }}
steps:
- uses: actions/checkout@v3
- name: Install dayjs
run: npm install dayjs
- name: Block if Silent
id: block
if: "!contains(github.event.head_commit.message, '--skip')"
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
if [[ "$COMMIT_MESSAGE" == *"--skip"* ]]; then
echo "::set-output name=run_jobs::false"
else
echo "::set-output name=run_jobs::true"
fi
- name: Create 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"
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.4-$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: Push Notification Payload
uses: tsickert/[email protected]
if: ${{ github.action_repository == 'CraftCanvasMC/Canvas' || github.repository == 'CraftCanvasMC/Canvas' }}
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
raw-data: push.json
deploy:
needs:
- kill-silent
if: needs.kill-silent.outputs.run_rest_jobs == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
distribution: temurin
java-version: 22
cache: 'gradle'
- name: Setup Node-14
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install dayjs
run: npm install dayjs
- name: Batch and Deploy
run: |
git config --global user.email "[email protected]" && git config --global user.name "Github Actions"
./gradlew applyPatches --no-daemon
./gradlew createCanvasServer --no-daemon
- name: Fallback
if: ${{ failure() }}
run: |
./gradlew clean cleanCache
./gradlew applyPatches --no-daemon
./gradlew createCanvasServer --no-daemon
- name: Prepare Hash
run: echo "COMMIT_HASH=$(git log --format='%H' -n 1)" >> $GITHUB_ENV
id: set_commit_hash
- name: Build Release Data
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.4]"
token: ${{ secrets.GIT_TOKEN }}
files: target/*.jar
- name: Create Payload
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.4-$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: Push Notification Payload
if: ${{ github.action_repository == 'CraftCanvasMC/Canvas' || github.repository == 'CraftCanvasMC/Canvas' }}
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
raw-data: push.json