-
Would like to automate the process of updating my website's robot.txt based on latest changes made to this repository's robot.txt, but I'm not sure what a good aproach would be to make this as easy and effective. Before suggesting anything, let me clear some stuff up:
Right now, what I would assume I could do is regularely pull the robots.txt and compare it with my own. If they differ, update the file and commit the change. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Do you want to be sure to get the latest released version of robots.txt or just the current latest version on the main branch? The process you describe would appear to pull the latest version on the main branch. So, if a bug was introduced and later corrected before release, you could end up committing the buggy version. |
Beta Was this translation helpful? Give feedback.
-
Managed to setup the following Actions file: name: "Update robots.txt"
on:
schedule:
- cron: "0 12 * * 0" # Once a week
workflow_dispatch:
jobs:
updateRobotsFile:
runs-on: codeberg-tiny-lazy
container:
image: ghcr.io/catthehacker/ubuntu:act-latest
steps:
- name: "Checkout website repository"
uses: https://code.forgejo.org/actions/checkout@v4
with:
token: ${{ secrets.BOT_TOKEN }}
path: source
- name: "Checkout ai.robots.txt Repository"
run: "git clone https://github.com/ai-robots-txt/ai.robots.txt remote"
- name: "Update file if different"
run: |
if git diff --no-index --exit-code "source/docs/robots.txt" "remote/robots.txt"; then
echo "No difference found."
else
echo "Difference found. Updating file."
cp "remote/robots.txt" "source/docs/robots.txt"
cd source
git config --global user.email "[email protected]"
git config --global user.name "Andre601's Bot"
git remote set-url origin https://${{ secrets.BOT_TOKEN }}@codeberg.org/Andre601/website
git add docs/robots.txt
git commit -m "Update robots.txt from ai.robots.txt"
git push
echo "Done!"
fi This seems to do the job for what I need. |
Beta Was this translation helpful? Give feedback.
Managed to setup the following Actions file: