Fetch Remote Assets #320
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 Remote Assets | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '00 12 * * *' # Should run 1 hour after module list update. | |
env: | |
MODULES_LIST_URL: "https://raw.githubusercontent.com/nesi/modules-list/main/module-list.json" | |
MODULES_UPDATE_URL: "https://raw.githubusercontent.com/nesi/modules-list/main/rss.xml" | |
GLOSSARY_URL: "https://raw.githubusercontent.com/nesi/nesi-wordlist/main/outputs/glossary.md" | |
DICTIONARY_URL: "https://raw.githubusercontent.com/nesi/nesi-wordlist/main/outputs/dictionary.txt" | |
SNIPPETS_URL: "https://raw.githubusercontent.com/nesi/nesi-wordlist/main/outputs/snippets.md" | |
BRANCH_NAME: "assets-update" | |
TARGET_OWNER: "nesi" | |
TARGET_REPO: "support-docs" | |
jobs: | |
fetch-includes: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Set Up Env" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- run: | | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
# git config pull.rebase true | |
git pull origin ${BRANCH_NAME} || git checkout -b ${BRANCH_NAME} | |
git fetch | |
git merge ${GITHUB_REF} | |
mkdir -pv docs/assets/glossary | |
- name: Module List | |
run: | | |
wget -O docs/assets/module-list.json ${MODULES_LIST_URL} | |
wget -O docs/software_updates.xml ${MODULES_UPDATE_URL} | |
python3 .github/workflows/link_apps_pages.py | |
git add --all | |
git commit -m "Updated Module List" || (echo "No Changes";exit 0) | |
- name: Fetch Wordlist | |
run: | | |
wget -O overrides/partials/glossary.html ${GLOSSARY_URL} | |
wget -O docs/assets/glossary/dictionary.txt ${DICTIONARY_URL} | |
wget -O docs/assets/glossary/snippets.md ${SNIPPETS_URL} | |
git add --all | |
git commit -m "Updated Glossary" || (echo "No Changes";exit 0) | |
- name: Commit to Branch | |
id: commit | |
run: | | |
git fetch | |
body_message="This Merge Request was triggered by an update to $(git diff --name-only ${GITHUB_REF} | tr '\n' ', ')." | |
if [[ $(git log ${GITHUB_REF}..HEAD) ]]; then | |
git push origin ${BRANCH_NAME} | |
# gh pr create -B ${GITHUB_REF} -H ${BRANCH_NAME} --title "Automatic Asset Update - $(date +'%Y-%m-%d')" --body "${body_message}" -l auto_merge | |
#gh workflow run -R nesi/support-docs -r assets-update -f fileList=" " checks.yml | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.PAT }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/${TARGET_OWNER}/${TARGET_REPO}/pulls \ | |
-d '{"title":"Automatic Asset Update - $(date +'%Y-%m-%d')" ,"body"::${body_message}"","head":"$BRANCH_NAME","base":"main"}' | |
else | |
echo "no changes" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |