From aa56ac973eb347b1daf311429daa642d9a7f9cd7 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Sun, 24 Nov 2024 22:11:25 +0000 Subject: [PATCH] Create documentation workflow --- .github/workflows/main.yml | 53 ++++++++++++++++++++++++++++++++++++++ _generator/generate | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..1d94b0761 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,53 @@ +name: Generate Documentation + +on: + pull_request: + branches: [ main ] + repository_dispatch: + types: [ generate ] + workflow_dispatch: + schedule: + - cron: '15 5 * * *' + +permissions: + contents: read + +jobs: + build: + # Only run scheduled workflows on the main repository; prevents people + # from using build minutes on their forks. + if: github.repository == 'libgit2/www.libgit2.org-docs' + name: "Generate documentation" + runs-on: "ubuntu-latest" + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + path: docs + fetch-depth: 0 + ssh-key: ${{ secrets.DOCS_PUBLISH_KEY }} + - name: Generate documentation + run: | + npm install + ./generate .. + working-directory: docs/_generator + - name: Examine changes + run: | + if [ -n "$(git diff --name-only)" ]; then + echo "changes=true" >> $GITHUB_OUTPUT + else + echo "changes=false" >> $GITHUB_OUTPUT + fi + id: check + working-directory: docs + - name: Publish documentation + run: | + DATE=$(date +"%Y-%m-%d") + + git config user.name 'Documentation Site Generator' + git config user.email 'libgit2@users.noreply.github.com' + git add . + git commit -m"Documentation update ${DATE}" + git push origin main + if: steps.check.outputs.changes == 'true' + working-directory: docs diff --git a/_generator/generate b/_generator/generate index 492f0d3c7..da1dcde9a 100755 --- a/_generator/generate +++ b/_generator/generate @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash set -eo pipefail