Update Sitemap #61
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: Update Sitemap | |
on: | |
schedule: | |
- cron: '0 0 * * 0' | |
workflow_dispatch: | |
jobs: | |
sitemap_job: | |
runs-on: ubuntu-latest | |
name: Generate a sitemap | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Generate the sitemap | |
id: sitemap | |
uses: cicirello/generate-sitemap@v1 | |
with: | |
drop-html-extension: true | |
base-url-path: https://jasoncameron.dev | |
- name: commit files | |
run: | | |
git config --global user.name "Jason | Sitemap Updater" | |
git config --global user.email "jasoncameron.all@gmail.com" | |
git add . | |
git rm *.pyc -f || echo | |
# "echo" returns true so the build succeeds, even if no changed files | |
git commit -m 'Update Sitemap file' || echo | |
git push | |
- name: notify google/bing that there is a new sitemap | |
env: | |
CUSTOM_URL: "${{ secrets.SITEMAP_URL }}" # set custom URL if you use it | |
SITEMAP_FILE: "sitemap.xml" | |
run: | | |
if [ -z "${CUSTOM_URL}" ]; then | |
if [ -s "CNAME" ]; then | |
MAP_URL="$(cat CNAME)" | |
else | |
MAP_URL="$(echo ${{ github.repository }} | sed -e "s/^.*${{ github.github.repository_owner }}\///")" | |
fi | |
MAP_URL="https://${MAP_URL}/${SITEMAP_FILE}" | |
else | |
MAP_URL="${CUSTOM_URL}" | |
fi | |
curl -v "https://www.google.com/ping?sitemap=${MAP_URL}" &> /dev/null & | |
curl -v "https://web.archive.org/save/jasoncameron.dev" &> /dev/null & | |
curl -v "https://www.bing.com/ping?sitemap=${MAP_URL}" &> /dev/null & | |
wait | |
printf "\n\nDone\n" | |