List backup repositories of a module #1236
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: apidoc | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/apidoc.yml' | |
- '**/validate-input.json' | |
- '**/validate-output.json' | |
- '**/validator-definitions.json' | |
pull_request: | |
types: [opened, synchronize, closed] | |
paths: | |
- '.github/workflows/apidoc.yml' | |
- '**/validate-input.json' | |
- '**/validate-output.json' | |
- '**/validator-definitions.json' | |
jobs: | |
push_image: | |
name: 'Build API docs for ${{ github.head_ref }}' | |
runs-on: ubuntu-22.04 | |
steps: | |
- id: checkout | |
uses: actions/checkout@v4 | |
- id: configure | |
name: "Configure git environment" | |
run: | | |
git config user.name nethbot | |
git config user.email [email protected] | |
- id: schemadocs | |
name: "Build the images" | |
if: "${{ github.event_name == 'push' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize')) }}" | |
run: | | |
# Build the images | |
set -e | |
buildah from --name schemadocs -v "${PWD}:/usr/src:Z" docker.io/library/node:slim | |
buildah run schemadocs npm install -g @adobe/jsonschema2md | |
buildah run schemadocs sh <<'EOF' | |
set -e | |
cd /usr/src | |
rm -rf .apidoc/{dst,src} | |
for MODULE_DIR in $(find . -type d -name imageroot -printf '%h\n'); do | |
SRCDIR=.apidoc/src/${MODULE_DIR#./} | |
DSTDIR=.apidoc/dst/${MODULE_DIR#./} | |
mkdir -vp ${SRCDIR} | |
find ${MODULE_DIR} -name validate-input.json -o -name validate-output.json -o -name validator-definitions.json | node .apidoc/id-rename.js ${SRCDIR} | |
jsonschema2md -d ${SRCDIR} -o ${DSTDIR} -x ${DSTDIR} -e json | |
done | |
EOF | |
- id: publish | |
name: "Publish the API documents" | |
if: "${{ github.event_name == 'push' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize')) }}" | |
run: | | |
# Publish the API documents | |
set -e | |
git add .apidoc/dst | |
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') | |
if (( PR_NUMBER > 0 )); then | |
COMMIT_MESSAGE="apidoc@${{ github.head_ref }} #${PR_NUMBER}" | |
REMOTE_BRANCH="apidoc-${{ github.head_ref }}" | |
else | |
BRANCH=$(basename ${{ github.ref }}) | |
COMMIT_MESSAGE="apidoc@$BRANCH" | |
REMOTE_BRANCH="apidoc" | |
fi | |
TREE=$(git write-tree --prefix=.apidoc/dst) | |
COMMIT=$(git commit-tree -m "${COMMIT_MESSAGE}" ${TREE}) | |
git push -f origin $COMMIT:refs/heads/${REMOTE_BRANCH} | |
echo "API documentation has been published to" | |
echo "" | |
echo " https://github.com/${{ github.repository }}/tree/${REMOTE_BRANCH}" | |
echo "" | |
- id: cleanup | |
name: "Cleanup apidoc-${{ github.head_ref }} branch" | |
if: "github.event_name == 'pull_request' && github.event.action == 'closed'" | |
run: | | |
git push -f origin :refs/heads/apidoc-${{ github.head_ref }} |