forked from SkriptLang/Skript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/death-evt-iscurrentevent
- Loading branch information
Showing
154 changed files
with
5,016 additions
and
1,751 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Cleanup nightly documentation | ||
on: delete | ||
jobs: | ||
cleanup-nightly-docs: | ||
if: github.event.ref_type == 'branch' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure workflow | ||
id: configuration | ||
env: | ||
DELETED_BRANCH: ${{ github.event.ref }} | ||
run: | | ||
BRANCH_NAME="${DELETED_BRANCH#refs/*/}" | ||
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT | ||
echo "DOCS_OUTPUT_DIR=${GITHUB_WORKSPACE}/skript-docs/docs/nightly/${BRANCH_NAME}" >> $GITHUB_OUTPUT | ||
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT | ||
- name: Checkout Skript | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.repository.default_branch }} | ||
submodules: recursive | ||
path: skript | ||
- name: Setup documentation environment | ||
uses: ./skript/.github/workflows/docs/setup-docs | ||
with: | ||
docs_deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }} | ||
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }} | ||
- name: Cleanup nightly documentation | ||
env: | ||
DOCS_OUTPUT_DIR: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }} | ||
run: | | ||
rm -rf ${DOCS_OUTPUT_DIR} || true | ||
- name: Push nightly documentation cleanup | ||
uses: ./skript/.github/workflows/docs/push-docs | ||
with: | ||
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }} | ||
git_name: Nightly Docs Bot | ||
git_email: nightlydocs@skriptlang.org | ||
git_commit_message: "Delete ${{ steps.configuration.outputs.BRANCH_NAME }} branch nightly docs" |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: Generate documentation | ||
|
||
inputs: | ||
docs_output_dir: | ||
description: "The directory to generate the documentation into" | ||
required: true | ||
type: string | ||
docs_repo_dir: | ||
description: "The skript-docs repository directory" | ||
required: true | ||
type: string | ||
skript_repo_dir: | ||
description: "The skript repository directory" | ||
required: true | ||
type: string | ||
is_release: | ||
description: "Designates whether to generate nightly or release documentation" | ||
required: false | ||
default: false | ||
type: boolean | ||
cleanup_pattern: | ||
description: "A pattern designating which files to delete when cleaning the documentation output directory" | ||
required: false | ||
default: "*" | ||
type: string | ||
|
||
outputs: | ||
DOCS_CHANGED: | ||
description: "Whether or not the documentation has changed since the last push" | ||
value: ${{ steps.generate.outputs.DOCS_CHANGED }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: generate-docs | ||
id: generate | ||
shell: bash | ||
env: | ||
DOCS_OUTPUT_DIR: ${{ inputs.docs_output_dir }} | ||
DOCS_REPO_DIR: ${{ inputs.docs_repo_dir }} | ||
SKRIPT_REPO_DIR: ${{ inputs.skript_repo_dir }} | ||
IS_RELEASE: ${{ inputs.is_release }} | ||
CLEANUP_PATTERN: ${{ inputs.cleanup_pattern }} | ||
run: | | ||
replace_in_directory() { | ||
find $1 -type f -exec sed -i -e "s/$2/$3/g" {} \; | ||
} | ||
# this should be replaced with a more reliable jq command, | ||
# but it can't be right now because docs.json is actually not valid json. | ||
get_skript_version_of_directory() { | ||
grep skriptVersion "$1/docs.json" | cut -d\" -f 4 | ||
} | ||
if [ -d "${DOCS_REPO_DIR}/docs/templates" ] | ||
then | ||
export SKRIPT_DOCS_TEMPLATE_DIR=${DOCS_REPO_DIR}/docs/templates | ||
else | ||
export SKRIPT_DOCS_TEMPLATE_DIR=${DOCS_REPO_DIR}/doc-templates | ||
fi | ||
export SKRIPT_DOCS_OUTPUT_DIR=/tmp/generated-docs | ||
cd $SKRIPT_REPO_DIR | ||
if [[ "${IS_RELEASE}" == "true" ]]; then | ||
./gradlew genReleaseDocs releaseJavadoc | ||
else | ||
./gradlew genNightlyDocs javadoc | ||
fi | ||
if [ -d "${DOCS_OUTPUT_DIR}" ]; then | ||
mkdir -p "${SKRIPT_DOCS_OUTPUT_DIR}/javadocs" && cp -a "./build/docs/javadoc/." "$_" | ||
mkdir -p "/tmp/normalized-output-docs" && cp -a "${DOCS_OUTPUT_DIR}/." "$_" | ||
mkdir -p "/tmp/normalized-generated-docs" && cp -a "${SKRIPT_DOCS_OUTPUT_DIR}/." "$_" | ||
|
||
output_skript_version=$(get_skript_version_of_directory "/tmp/normalized-output-docs") | ||
generated_skript_version=$(get_skript_version_of_directory "/tmp/normalized-generated-docs") | ||
|
||
replace_in_directory "/tmp/normalized-output-docs" "${output_skript_version}" "Skript" | ||
replace_in_directory "/tmp/normalized-generated-docs" "${generated_skript_version}" "Skript" | ||
|
||
diff -qbr /tmp/normalized-output-docs /tmp/normalized-generated-docs || diff_exit_code=$? | ||
# If diff exits with exit code 1, that means there were some differences | ||
if [[ ${diff_exit_code} -eq 1 ]]; then | ||
echo "DOCS_CHANGED=true" >> $GITHUB_OUTPUT | ||
echo "Documentation has changed since last push" | ||
else | ||
echo "Documentation hasn't changed since last push" | ||
fi | ||
else | ||
echo "DOCS_CHANGED=true" >> $GITHUB_OUTPUT | ||
echo "No existing documentation found" | ||
fi | ||
|
||
rm -rf ${DOCS_OUTPUT_DIR}/${CLEANUP_PATTERN} || true | ||
mkdir -p "${DOCS_OUTPUT_DIR}/" && cp -a "${SKRIPT_DOCS_OUTPUT_DIR}/." "$_" | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Push documentation | ||
|
||
inputs: | ||
docs_repo_dir: | ||
description: "The skript-docs repository directory" | ||
required: true | ||
type: string | ||
git_email: | ||
description: "The email to use for the Git commit" | ||
required: true | ||
type: string | ||
git_name: | ||
description: "The name to use for the Git commit" | ||
required: true | ||
type: string | ||
git_commit_message: | ||
description: "The message to use for the Git commit" | ||
required: true | ||
type: string | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- shell: bash | ||
if: success() | ||
env: | ||
DOCS_REPO_DIR: ${{ inputs.docs_repo_dir }} | ||
GIT_EMAIL: ${{ inputs.git_email }} | ||
GIT_NAME: ${{ inputs.git_name }} | ||
GIT_COMMIT_MESSAGE: ${{ inputs.git_commit_message }} | ||
run: | | ||
cd "${DOCS_REPO_DIR}" | ||
git config user.name "${GIT_NAME}" | ||
git config user.email "${GIT_EMAIL}" | ||
git add -A | ||
git commit -m "${GIT_COMMIT_MESSAGE}" || (echo "Nothing to push!" && exit 0) | ||
# Attempt rebasing and pushing 5 times in case another job pushes before us | ||
for i in 1 2 3 4 5 | ||
do | ||
git pull --rebase -X theirs origin main | ||
git push origin main && break | ||
sleep 5 | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Setup documentation environment | ||
|
||
inputs: | ||
docs_deploy_key: | ||
description: "Deploy key for the skript-docs repo" | ||
required: true | ||
type: string | ||
docs_output_dir: | ||
description: "The directory to generate the documentation into" | ||
required: true | ||
type: string | ||
cleanup_pattern: | ||
description: "A pattern designating which files to delete when cleaning the documentation output directory" | ||
required: false | ||
default: "*" | ||
type: string | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout skript-docs | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: 'SkriptLang/skript-docs' | ||
path: skript-docs | ||
ssh-key: ${{ inputs.docs_deploy_key }} | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
cache: gradle | ||
- shell: bash | ||
run: chmod +x ./skript/gradlew | ||
- shell: bash | ||
env: | ||
DOCS_DEPLOY_KEY: ${{ inputs.docs_deploy_key }} | ||
DOCS_OUTPUT_DIR: ${{ inputs.docs_output_dir }} | ||
CLEANUP_PATTERN: ${{ inputs.cleanup_pattern }} | ||
run: | | ||
eval `ssh-agent` | ||
echo "$DOCS_DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null | ||
mkdir ~/.ssh | ||
ssh-keyscan www.github.com >> ~/.ssh/known_hosts |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Nightly documentation | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- '**' | ||
|
||
jobs: | ||
nightly-docs: | ||
if: "!contains(toJSON(github.event.commits.*.message), '[ci skip]')" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure workflow | ||
id: configuration | ||
env: | ||
DOCS_DEPLOY_KEY: ${{ secrets.DOCS_DEPLOY_KEY }} | ||
run: | | ||
if [ -n "$DOCS_DEPLOY_KEY" ] | ||
then | ||
echo "DOCS_DEPLOY_KEY_PRESENT=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "Secret 'DOCS_DEPLOY_KEY' not present. Exiting job." | ||
fi | ||
BRANCH_NAME="${GITHUB_REF#refs/*/}" | ||
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT | ||
echo "DOCS_OUTPUT_DIR=${GITHUB_WORKSPACE}/skript-docs/docs/nightly/${BRANCH_NAME}" >> $GITHUB_OUTPUT | ||
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT | ||
echo "SKRIPT_REPO_DIR=${GITHUB_WORKSPACE}/skript" >> $GITHUB_OUTPUT | ||
- name: Checkout Skript | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
path: skript | ||
- name: Setup documentation environment | ||
if: steps.configuration.outputs.DOCS_DEPLOY_KEY_PRESENT == 'true' | ||
uses: ./skript/.github/workflows/docs/setup-docs | ||
with: | ||
docs_deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }} | ||
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }} | ||
- name: Generate documentation | ||
id: generate | ||
if: steps.configuration.outputs.DOCS_DEPLOY_KEY_PRESENT == 'true' | ||
uses: ./skript/.github/workflows/docs/generate-docs | ||
with: | ||
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }} | ||
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }} | ||
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }} | ||
- name: Push nightly documentation | ||
if: steps.generate.outputs.DOCS_CHANGED == 'true' | ||
uses: ./skript/.github/workflows/docs/push-docs | ||
with: | ||
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }} | ||
git_name: Nightly Docs Bot | ||
git_email: nightlydocs@skriptlang.org | ||
git_commit_message: "Update ${{ steps.configuration.outputs.BRANCH_NAME }} branch nightly docs to ${{ github.repository }}@${{ github.sha }}" |
Oops, something went wrong.