Merge remote-tracking branch 'upstream/main' #194
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: Fetch, Deploy KERISSE and Update Glossary | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
glossaryDefFile: | |
required: true | |
default: glossary.json | |
description: glossaryDefFile | |
deployBranch: | |
required: false | |
default: gh-pages | |
description: This is where the output of script will be pushed to. | |
# gollum: | |
# gollum run on wiki-changes | |
permissions: | |
actions: write | |
contents: write | |
pull-requests: write | |
statuses: write | |
jobs: | |
deploy: | |
name: Fetch Content and Deploy to GitHub Pages | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19 | |
cache: npm | |
- name: Install dependencies | |
run: npm ci | |
############################## | |
# Google sheet: WOT-terms, tab: Terms-WOT-manage | |
############################## | |
- name: Import Google Sheet “WOT-terms”, tab “Terms-WOT-manage” data into markdown file | |
env: | |
TERMS_WOT_MANAGE_MARKDOWN: ./docs/02_overview/overview-and-context.mdx | |
TERMS_WOT_MANAGE_JSON_DIR_NAME: ./static/json/ | |
TERMS_WOT_MANAGE_JSON_FILE_NAME: overview.json | |
TERMS_WOT_MANAGE_JSON_ENDPOINT: ${{ secrets.TERMS_WOT_MANAGE_JSON_ENDPOINT }} | |
run: node fetchExternalContent/fetchTermsWOTmanage/fetchTermsWOTmanage.mjs | |
############################## | |
############################## | |
# Google sheet: WOT-terms, tab: LabelContent (Carbon copies) | |
############################## | |
- name: Import Google Sheet “WOT-terms”, tab “LabelContent” (Carbon copies) data into markdown file | |
env: | |
CARBON_COPIES_OUTPUT_DIR: ./docs/08_carbon-copies/ | |
CARBON_COPIES_INPUT_DIR: ./static/json/externalContentMetaData.json | |
run: sh fetchExternalContent/fetchCarbonCopies/main.sh | |
############################## | |
############################## | |
# Google sheet: WOT-terms, tab: GenericScraper | |
############################## | |
- name: Import Google Sheet “WOT-terms”, tab “GenericScraper” data into markdown file | |
env: | |
SEARCH_INDEX_DIR: search-index-typesense | |
GENERIC_SCRAPER_JSON_ENDPOINT: ${{ secrets.GENERIC_SCRAPER_JSON_ENDPOINT }} | |
run: node fetchExternalContent/fetchSingleUrlsFromWotTermsGoogleSheet/fetchSingleUrlsFromWotTermsGoogleSheet.js | |
############################## | |
############################## | |
# Clones the wiki | |
############################## | |
- name: Checkout wiki | |
env: | |
GLOSSARY_OVERVIEW_JSON_LABEL: Glossary | |
GLOSSARY_OVERVIEW_JSON_DESCRIPTION: Web of Trust Glossary | |
run: | | |
git clone https://github.com/WebOfTrust/WOT-terms.wiki.git temp-wiki | |
# remove the .git folder | |
rm -rf temp-wiki/.git | |
rm -rf temp-wiki/.gitignore | |
# Create a file in temp-wiki/ called ”_category_.json” | |
echo "{ | |
\"label\": \"${GLOSSARY_OVERVIEW_JSON_LABEL}\", | |
\"link\": { | |
\"type\": \"generated-index\", | |
\"description\": \"${GLOSSARY_OVERVIEW_JSON_DESCRIPTION}.\" | |
} | |
}" > temp-wiki/_category_.json | |
# Copies the wiki contents to the /docs/04_glossary/ directory | |
- name: Copy Wiki To Docusaurus Glossary directory | |
run: | | |
mkdir -p docs/04_glossary # Create the directory if it doesn't exist | |
# Copy all new and updated files from temp-wiki/ to docs/04_glossary/ | |
# Delete any files in docs/04_glossary/ that do not exist in temp-wiki/ | |
rsync -a --delete --exclude='.gitignore' temp-wiki/ docs/04_glossary/ | |
# The /temp-wiki directory is not needed anymore | |
rm -rf temp-wiki/ # Remove the /temp-wiki directory | |
############################## | |
############################## | |
# Create JSON from Github wiki files | |
############################## | |
- name: Fix dashes in filenames coming from Wiki | |
env: | |
GLOSSARY_DIR: 04_glossary | |
GENERATED_JSON_GLOSSARIES_DIR: ./static/json/external-glosseries/glossaries/ | |
run: node fetchExternalContent/fetchMentalModels/fetchWotTermsContent/fetchWotTermsContent.mjs | |
############################## | |
############################## | |
# Fix dashes in filenames coming from Wiki | |
############################## | |
- name: Fix dashes in filenames coming from Wiki | |
env: | |
GLOSSARY_DIR: 04_glossary | |
run: node maintenance/fixDashInWikiCopyFilenames.js | |
############################## | |
############################## | |
# Fetch external glossary content | |
############################## | |
- name: Fetch external glossary content | |
env: | |
GENERATED_JSON_GLOSSARIES_DIR: ./static/json/external-glosseries/glossaries/ | |
GENERATED_JSON_GLOSSARIES_COMBINED_DIR: ./static/json/external-glosseries/glossaries-combined/ | |
run: sh fetchExternalContent/fetchMentalModels/main.sh | |
############################## | |
############################## | |
# Fix svg's created by OmniGraffle | |
############################## | |
- name: Fix svg's created by OmniGraffle | |
run: node maintenance/fixOmnigraffleSvgOutput.js | |
############################## | |
# # CURRENTLY MANUALLY RUN | |
# ############################## | |
# # Find broken links and create a Github issue | |
# ############################## | |
# - name: Find broken links and create a Github issue | |
# run: node maintenance/findBrokenLinks.js | |
# ############################## | |
############################## | |
# Pushes the changes into the repo | |
############################## | |
- name: Commit and push the changes after fetching content from various external sources | |
run: | | |
echo "Initial status:" | |
git status | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add -A | |
echo "Status after git add:" | |
git status | |
git diff --cached --exit-code && exit 0 # Exit if no changes in the staging area | |
echo "Committing changes:" | |
git commit -m "chore: fetch content from various external sources" | |
echo "Pushing changes:" | |
git push | |
echo "Final status:" | |
git status | |
############################## | |
############################## | |
# Builds the website to /build | |
############################## | |
- name: Build website | |
run: npm run build | |
############################## | |
############################## | |
# Popular action to deploy to GitHub Pages: | |
############################## | |
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# Build output to publish to the `gh-pages` branch: | |
publish_dir: ./build | |
# The following lines assign commit authorship to the official | |
# GH-Actions bot for deploys to `gh-pages` branch: | |
# https://github.com/actions/checkout/issues/13#issuecomment-724415212 | |
# The GH actions bot is used by default if you didn't specify the two fields. | |
# You can swap them out with your own user credentials. | |
user_name: github-actions[bot] | |
user_email: 41898282+github-actions[bot]@users.noreply.github.com | |
############################## | |
update-glossary: | |
name: Update Glossary | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v2.2.2 | |
- name: Install deps | |
run: | | |
git clone https://github.com/trustoverip/tt.git | |
python -m pip install marko | |
python -m pip install requests | |
- name: Set variables | |
env: | |
DEFAULT_GLOSSARY_DEF_FILE: glossary.json | |
DEFAULT_DEPLOY_BRANCH: gh-pages | |
run: | | |
echo "GLOSSARY_DEF_FILE=${{ github.event.inputs.glossaryDefFile || env.DEFAULT_GLOSSARY_DEF_FILE }}" >> $GITHUB_ENV | |
echo "DEPLOY_BRANCH=${{ github.event.inputs.deployBranch || env.DEFAULT_DEPLOY_BRANCH }}" >> $GITHUB_ENV | |
- name: Run script | |
run: ./tt/bin/tt glossary ${{ env.GLOSSARY_DEF_FILE }} >glossary.html.new | |
- name: Setup git config | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
# - name: Check and delete /static/glossary.html in main if exists | |
# run: | | |
# git checkout main | |
# if [ -f "./static/glossary.html" ]; then | |
# git rm ./static/glossary.html | |
# git commit -m "Remove existing glossary.html from /static/ directory" | |
# git push | |
# fi | |
# git checkout ${{ env.DEPLOY_BRANCH }} | |
- name: Publishing | |
run: | | |
git fetch origin | |
git checkout ${{ env.DEPLOY_BRANCH }} | |
mv glossary.html.new glossary.html | |
git add glossary.html | |
git diff --cached --exit-code && exit 0 # Exit if no changes in the staging area | |
git commit -m "auto-update glossary" | |
git push | |
echo DONE | |
- name: Copy glossary.html to /static/ directory of the original branch2 | |
run: | | |
git fetch origin | |
git checkout ${{ env.DEPLOY_BRANCH }} # Switch back to the DEPLOY_BRANCH | |
cp glossary.html ../glossary.html.temp # Temporary copy | |
git checkout main # Switch back to the original branch (assuming it's 'main') | |
git pull origin main --rebase # Make sure local main is in sync with remote | |
cp ../glossary.html.temp ./static/glossary.html # Copy the existing glossary.html to the /static/ directory | |
if [ $? -eq 0 ]; then | |
echo "Successfully copied glossary.html to /static/ directory." | |
else | |
echo "Failed to copy glossary.html to /static/ directory." | |
exit 1 | |
fi | |
git add ./static/glossary.html | |
git diff --cached --exit-code && exit 0 # Exit if no changes in the staging area | |
git commit -m "Copy glossary.html to /static/ directory" | |
git push | |