cFS Documentation and Guides Script #162
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: cFS Documentation and Guides Script | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
# 10:45 PM UTC every Sunday | |
- cron: '45 22 * * 0' | |
permissions: | |
contents: write | |
jobs: | |
# Checks for duplicate actions. Skips push actions if there is a matching or | |
# duplicate pull-request action. | |
checks-for-duplicates: | |
runs-on: ${{ github.repository_owner == 'cFS' && 'linux' || 'ubuntu-latest' }} | |
# Map a step output to a job output | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@master | |
with: | |
concurrent_skipping: 'same_content' | |
skip_after_successful_duplicate: 'true' | |
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' | |
checkout-and-cache: | |
name: Custom checkout and cache for cFS documents | |
needs: checks-for-duplicates | |
if: ${{ needs.checks-for-duplicates.outputs.should_skip != 'true' || contains(github.ref, 'main') }} | |
runs-on: ${{ github.repository_owner == 'cFS' && 'linux' || 'ubuntu-latest' }} | |
steps: | |
- name: Checkout bundle | |
uses: actions/checkout@v3 | |
with: | |
repository: arielswalker/cFS | |
submodules: true | |
- name: Checkout submodule | |
uses: actions/checkout@v3 | |
with: | |
path: cfe | |
- name: Cache Source and Build | |
id: cache-src-bld | |
uses: actions/cache@v3 | |
with: | |
path: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/* | |
key: cfs-doc-${{ github.run_number }} | |
build-docs: | |
needs: checkout-and-cache | |
name: Build cFE and Mission Docs | |
runs-on: ${{ github.repository_owner == 'cFS' && 'linux' || 'ubuntu-latest' }} | |
env: | |
CACHE_KEY: "cfs-doc-${{ github.run_number }}" | |
strategy: | |
matrix: | |
target: ['cfe-usersguide', 'mission-doc'] | |
steps: | |
- name: Get cache if supplied | |
id: cache-src-bld | |
if: ${{ env.CACHE_KEY != '' }} | |
uses: actions/cache@v4 | |
with: | |
path: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/* | |
key: ${{ env.CACHE_KEY }} | |
- name: Set Unique Variables | |
id: set-target | |
run: | | |
if [ "${{ matrix.target }}" == "cfe-usersguide" ]; then | |
echo "BUILD_PDF=true" >> $GITHUB_ENV | |
echo "DEPLOY=true" >> $GITHUB_ENV | |
elif [ "${{ matrix.target }}" == "mission-doc" ]; then | |
echo "BUILD_PDF=false" >> $GITHUB_ENV | |
echo "DEPLOY=false" >> $GITHUB_ENV | |
fi | |
- name: Make the Script Executable | |
run: chmod +x ./.github/scripts/build-deploy-doc.sh | |
- name: Run CodeQL Analysis Script | |
run: ./.github/scripts/build-deploy-doc.sh | |
env: | |
TARGET: ${{ matrix.target }} | |
CACHE_KEY: "cfs-doc-${{ github.run_number }}" | |
DEPLOY: ${{ env.DEPLOY }} | |
BUILD_PDF: ${{ env.BUILD_PDF }} | |
APP_NAME: "" | |
NEEDS_OSAL_API: "true" | |
- name: Archive Document Build Logs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }}_doc_build_logs | |
path: | | |
${{ matrix.target }}_stdout.txt | |
${{ matrix.target }}_stderr.txt | |
${{ matrix.target }}-warnings.log | |
- name: Archive PDF | |
if: ${{ env.BUILD_PDF == 'true' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }}_pdf | |
path: ${{ matrix.target }}.pdf | |
- name: Move pdfs to deployment directory | |
if: ${{ (env.BUILD_PDF == 'true' && env.DEPLOY == 'true') }} | |
run: | | |
mkdir deploy | |
mv ${{ matrix.target }}.pdf deploy | |
ls -a | |
echo "cd in deploy" | |
cd deploy | |
ls -a | |
# Could add pandoc and convert to github markdown | |
# pandoc ${{ matrix.target }}.pdf -t gfm | |
- name: Deploy to GitHub | |
if: ${{ (env.BUILD_PDF == 'true' && env.DEPLOY == 'true') }} | |
uses: JamesIves/[email protected] | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BRANCH: gh-pages | |
FOLDER: deploy |