We'll put all of our Python code covered so far into a Google Cloud function that we can trigger when there are WordPress updates. Advertising Continue reading below In Banner Design summary, the code: Download XML sitemaps and check for the latest updated pages. Update/create a main.yml workflow file with a list of URLs to check. Commit the modified main.yml to the GitHub repository. However, we only want to call our code when there are new changes in WordPress. So how do we do this? Fortunately, WordPress has a Ping mechanism that we can use for this. Banner Design How to Run Automated Lighthouse Audits on WordPress Changes Just add our cloud function URL to the Ping service list. I tried reading the payload that WordPress sends to see if updated
URLs are included and unfortunately it still Banner Design listed the home page and site feed in my tests. How to Run Automated Lighthouse Audits on WordPress Changes If WordPress sent the updated list of URLs, we could skip the XML sitemap upload step. Banner Design Advertising Continue reading below Deploy cloud function Here are the steps to create the Cloud Function. Make sure to activate the service first. First, we need to authenticate with Google Compute Engine. ! gcloud auth login --no-launch-browser ! gcloud config set project project -name I created a summary with a working Cloud Function with all the steps to make this idea work. Please read the code Banner Design to customize it according to your details and the GitHub repository. I have also created a summary with the requirements.txt file that you need to include when deploying the Cloud Function. You need to download both files and have them in the same folder where you will run the following command. I moved GitHub credentials to use environment variables.
It's not a good idea to have them in source control. ! gcloud functions deploy wordpress_ping_post --runtime python37 --trigger-http --allow-unauthenticated --set-env-vars username= <your GitHub username> , password= <copy your private GitHub token> You should see output similar to the one below. How to Run Automated Lighthouse Audits on WordPress Banner Design Changes I have highlighted the URL you need to add your WordPress Ping service list. Advertising Continue reading below Resources for learning more and community projects I didn't include the performance budget part in my Cloud function. Please consider doing this as a homework assignment. Also, I encourage you Banner Design to set up a Lighthouse CI server and update the main.yml file to send the reports there. If you want a more familiar interface, consider this project from the awesome team at Local SEO Guide. It uses Data Studio as its reporting interface.