Manubot #400
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: Manubot | |
on: | |
push: | |
branches: | |
- main | |
- master | |
pull_request: | |
branches: | |
- main | |
- master | |
# NOTE: scheduled workflows are supported as of 2022-09-27 (example commented below) | |
# https://github.com/community/community/discussions/12269#discussioncomment-3747667 | |
schedule: | |
- cron: '0 1 * * 1' # https://crontab.guru/#0_1_*_*_1 | |
workflow_dispatch: | |
inputs: | |
BUILD_PDF: | |
type: boolean | |
description: generate PDF output | |
default: true | |
BUILD_DOCX: | |
type: boolean | |
description: generate DOCX output | |
default: false | |
BUILD_LATEX: | |
type: boolean | |
description: generate LaTeX output | |
default: false | |
SPELLCHECK: | |
type: boolean | |
description: Check spelling | |
default: true | |
MANUBOT_USE_DOCKER: | |
type: boolean | |
description: Use Docker to generate PDF | |
default: true | |
jobs: | |
manubot: | |
name: Manubot | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
GITHUB_PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }} | |
# Set SPELLCHECK to true/false for whether to check spelling in this action. | |
# For workflow dispatch jobs, this SPELLCHECK setting will be overridden by the user input. | |
SPELLCHECK: true | |
defaults: | |
run: | |
shell: bash --login {0} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
# fetch entire commit history to support get_rootstock_commit | |
fetch-depth: 0 | |
- name: Checkout yt Repository | |
uses: actions/checkout@v3 | |
with: | |
repository: yt-project/yt | |
path: yt | |
fetch-depth: 0 # We want to run stats on the whole thing | |
- name: Set Environment Variables (Workflow Dispatch) | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
echo "BUILD_PDF=${{ github.event.inputs.BUILD_PDF }}" >> $GITHUB_ENV | |
echo "BUILD_DOCX=${{ github.event.inputs.BUILD_DOCX }}" >> $GITHUB_ENV | |
echo "BUILD_LATEX=${{ github.event.inputs.BUILD_LATEX }}" >> $GITHUB_ENV | |
echo "SPELLCHECK=${{ github.event.inputs.SPELLCHECK }}" >> $GITHUB_ENV | |
echo "MANUBOT_USE_DOCKER=${{ github.event.inputs.MANUBOT_USE_DOCKER }}" >> $GITHUB_ENV | |
- name: Set Environment Variables | |
run: | | |
TRIGGERING_SHA=${GITHUB_PULL_REQUEST_SHA:-$GITHUB_SHA} | |
echo "TRIGGERING_SHA_7=${TRIGGERING_SHA::7}" >> $GITHUB_ENV | |
echo "TRIGGERING_SHA: $TRIGGERING_SHA" | |
DEFAULT_BRANCH=${{ github.event.repository.default_branch }} | |
echo "DEFAULT_BRANCH=${DEFAULT_BRANCH}" >> $GITHUB_ENV | |
echo "DEFAULT_BRANCH_REF=refs/heads/$DEFAULT_BRANCH" >> $GITHUB_ENV | |
echo "DEFAULT_BRANCH=$DEFAULT_BRANCH" | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: ci/cache | |
key: ci-cache-${{ github.ref }} | |
restore-keys: | | |
ci-cache-${{ env.DEFAULT_BRANCH_REF }} | |
- name: Anaconda cache | |
uses: actions/cache@v1 | |
env: | |
# Increase this value to reset cache if etc/example-environment.yml has not changed | |
CACHE_NUMBER: 0 | |
with: | |
path: ~/conda_pkgs_dir | |
key: conda-cache-${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('build/environment.yml') }} | |
- name: Install Environment | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
activate-environment: manubot | |
environment-file: build/environment.yml | |
auto-activate-base: false | |
miniforge-version: 'latest' | |
- name: Install Spellcheck | |
if: env.SPELLCHECK == 'true' | |
run: bash ci/install-spellcheck.sh | |
- name: Update yt stats | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api graphql --paginate -f query="`cat scripts/pull_request_graphql.gql`" > pull_requests.json | |
jq -s '[.[].data.repository.pullRequests.nodes[]]' < pull_requests.json > pr.json | |
python scripts/generate_stats.py | |
- name: Build Manuscript | |
run: bash build/build.sh | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: manuscript-${{ github.run_id }}-${{ env.TRIGGERING_SHA_7 }} | |
path: output | |
- name: Deploy Manuscript | |
if: github.ref == env.DEFAULT_BRANCH_REF && github.event_name != 'pull_request' && !github.event.repository.fork | |
env: | |
MANUBOT_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
MANUBOT_SSH_PRIVATE_KEY: ${{ secrets.MANUBOT_SSH_PRIVATE_KEY }} | |
CI_BUILD_WEB_URL: https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks | |
CI_JOB_WEB_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
run: bash ci/deploy.sh |