Auto update files on commit!

You'd never believe I spent all day on this! (Well, in between doing actual work)

After trying a whole bunch of different libraries and scripts, and trying unsuccessfully to learn CURL to use with github's api, I finally found a library that does what I need: https://github.com/KnpLabs/php-github-api

I can use it to get a list of commits, and compare the sha of the most recent one to one I saved earlier in a text file, so if there is a commit, then run getfileurls.php and update all the links :-)

I'd love to find a way to send myself a notification if there's ever a new page linked where I need to input a direct file link for the first time, but it doesn't look like there's any way to send web-based SMS messages for free. Maybe I can find a robot to send me messages in a Slack or Hangouts chat room. Email would be easy but there's no point, I don't check my email more than 1-3 times a day.

My program has a message area to put messages associated with the files (eg for an initial test I set the messages for every file whose path is /luma/payloads to "delete the files in /luma/payloads not ending in .bin and rename the .bin file according to the guide" so all I need to do is make a page to display the contents of the database and be able to edit it without opening up CPanel (so I can fix things on mobile), and make a button on the program to report errors, then I'll go alpha :-D Then, if all the wrong data gets fixed up, and people are actually interested in using it, I'll make a pull request to add the divs to the what you need sections, and it can run off the REAL guide!
  • Like
Reactions: 2 people

Comments

This sounds interesting. If I followed it right, it's a web app that'll always download the latest needed files from Plailect's guide and now you found a way for it to update automatically whenever new commits are done to the guide?
 
Yep :-) If I had failed at being able to do that it would make it less useful. An alternative is to just have the file updater script run regularly, but then there's a balance between how often to run it and how much of a time period to tell the program (eg all files with a timestamp within five minutes of the most recent one count as active). If this time period is too short then some files might not make it, if the script ran slowly. But if the script runs less regularly and the time period is longer then there's a higher risk someone might download an outdated file.

Something else I'll do later is get the list of files changed in the commit and only update the files on those. So the script will take a few seconds or a minute, not several minutes like now (since its recursively visiting every single page in the guide). The faster it runs the tinier the chance is someone could download something outdated :-)
 

Blog entry information

Author
Quantumcat
Views
130
Comments
6
Last update

More entries in Personal Blogs

More entries from Quantumcat

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: Blue waffles should be round!