category-doc-update #266
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: "Update category documentation" | |
on: | |
repository_dispatch: | |
types: [category-doc-update] | |
jobs: | |
update_category_docs: | |
name: "Update category documentation" | |
runs-on: "ubuntu-latest" | |
permissions: write-all | |
env: | |
FROM_REPO: ${{ github.event.client_payload.repo }} | |
FROM_TAG: ${{ github.event.client_payload.tag }} | |
steps: | |
- name: "Checkout the repository (main)" | |
if: ${{ github.event.client_payload.tag == 'dev' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: "Checkout the repository (stable)" | |
if: ${{ github.event.client_payload.tag != 'dev' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: stable | |
- name: "Download the new content" | |
run: | | |
CATEGORY_ID="${FROM_REPO#RiverBench/category-}" | |
VERSION_ID="${FROM_TAG#v}" | |
# Category | |
rm -rf "docs/categories/${CATEGORY_ID}" || true | |
mkdir -p "docs/categories/${CATEGORY_ID}" | |
cd "docs/categories/${CATEGORY_ID}" | |
wget "https://github.com/${FROM_REPO}/releases/download/${FROM_TAG}/docs.tar.gz" | |
tar -xzvf docs.tar.gz | |
mv ./category/* . || true | |
rm -r ./category | |
# Profiles | |
mkdir -p "../../profiles" || true | |
rm -f ../../profiles/${CATEGORY_ID}-*.md || true | |
mv ./profiles/*.md "../../profiles" || true | |
rm -r ./profiles | |
# Tasks | |
mkdir -p "../../tasks" || true | |
rm -rf ../../tasks/${CATEGORY_ID}-* || true | |
cp -r ./tasks/* ../../tasks || true | |
rm -r ./tasks | |
rm docs.tar.gz | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: ${{ format('Automatic update of {0} ({1})', github.event.client_payload.repo, github.event.client_payload.tag) }} | |
default_author: github_actions | |
add: 'docs/categories docs/profiles docs/tasks' | |
pull: '--rebase --autostash' | |
push: true | |
- name: "Trigger doc compilation" | |
if: ${{ github.event.client_payload.tag == 'dev' }} | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ secrets.PAT_DOC_REPO_HOOKS }} | |
event-type: compile-docs | |
client-payload: '{ "tag": "dev" }' |