Update jsonFunctions.md (#336) #307
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Wiki Deploy | |
on: | |
push: | |
branches: | |
- dev | |
- prod | |
jobs: | |
build: | |
name: Build wiki book | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install mdbook | |
uses: MineBartekSA/quick-mdbook@v1.1 | |
- name: Build book | |
run: mdbook build | |
- name: Upload book | |
uses: actions/upload-artifact@v3 | |
with: | |
name: book | |
path: book | |
deploy-prod: | |
name: Deploy production wiki | |
needs: build | |
if: github.ref == 'refs/heads/prod' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Prepare to fetch book | |
run: | | |
mv nightly .. | |
rm -rf * | |
- name: Fetch book artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: book | |
- name: Deploy | |
run: | | |
mv ../nightly . | |
git config user.name "Github Actions" | |
git config user.email "" | |
git add . | |
git commit -m "Deploy $GITHUB_SHA to gh-pages" | |
git push --force --set-upstream origin gh-pages | |
deploy-nightly: | |
name: Deploy nightly wiki | |
needs: build | |
if: github.ref == 'refs/heads/dev' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Prepare to fetch book | |
run: | | |
rm -rf nightly/* | |
- name: Fetch book artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: book | |
path: nightly | |
- name: Deploy | |
run: | | |
git config user.name "Github Actions" | |
git config user.email "" | |
git add . | |
git commit -m "Deploy nightly $GITHUB_SHA to gh-pages" | |
git push --force --set-upstream origin gh-pages | |
notify-discord: | |
name: Send notification | |
needs: [deploy-prod, deploy-nightly] | |
if: ${{ !failure() }} | |
runs-on: ubuntu-latest | |
env: | |
TYPE: Nightly | |
LINK: nightly | |
steps: | |
- name: Prepare notification | |
env: | |
RAW: ${{ github.event.head_commit.message }} | |
run: | | |
echo "MESSAGE<<EOF" >> $GITHUB_ENV | |
RAW=$(echo "$RAW" | sed -r '/^\s*$/d') | |
echo "$RAW" | head -n 10 | sed ':a;N;$!ba;s/\n/\n /g' >> $GITHUB_ENV | |
if [ $(echo "$RAW" | wc -l) -gt 10 ] | |
then | |
echo " ..." >> $GITHUB_ENV | |
fi | |
echo "EOF" >> $GITHUB_ENV | |
- name: Set notification type | |
if: github.ref == 'refs/heads/prod' | |
run: | | |
echo "TYPE=Production" >> $GITHUB_ENV | |
echo "LINK=" >> $GITHUB_ENV | |
- name: Send wiki update notification | |
uses: MineBartekSA/discord-webhook@v2.1 | |
with: | |
webhook: ${{ secrets.WEBHOOK }} | |
embed: | | |
title: "${{ env.TYPE }} Wiki Update" | |
color: 10001644 | |
author: | |
name: ${{ github.event.head_commit.author.username }} | |
url: https://github.com/${{ github.event.head_commit.author.username }} | |
icon_url: https://github.com/${{ github.event.head_commit.author.username }}.png | |
thumbnail: | |
url: https://botdesignerdiscord.com/logo512.png | |
description: | | |
**__Content__** | |
${{ env.MESSAGE }} | |
component: | | |
- type: 2 | |
style: 5 | |
label: Jump to commit | |
url: ${{ github.event.head_commit.url }} | |
- type: 2 | |
style: 5 | |
label: Jump to ${{ env.TYPE }} Wiki | |
url: https://nilpointer-software.github.io/bdfd-wiki/${{ env.LINK }} |