├── screenshots └── screenshot-output.png ├── package.json ├── .github └── workflows │ └── main.yml ├── action.yml ├── index.js └── README.md /screenshots/screenshot-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JakePartusch/psi-action/HEAD/screenshots/screenshot-output.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "psi-action", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@actions/core": "^1.9.1", 14 | "@actions/github": "^5.1.1", 15 | "psi": "^4.1.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | on: [push] 2 | 3 | jobs: 4 | run_psi: 5 | runs-on: ubuntu-latest 6 | name: Running Page Speed Insights 7 | steps: 8 | - name: Checkout 9 | uses: actions/checkout@v1 10 | - name: Running Page Speed Insights 11 | uses: ./ # Uses an action in the root directory 12 | id: psi 13 | with: 14 | url: "https://jake.partus.ch" 15 | threshold: 85 16 | strategy: mobile 17 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Page Speed Insights" 2 | description: "Utilize Google's Page Speed Insights to audit your application" 3 | branding: 4 | icon: "cloud-lightning" 5 | color: "green" 6 | inputs: 7 | url: 8 | description: "The URL to run the check against" 9 | required: true 10 | threshold: 11 | description: "Score to pass the PageSpeed test. Useful for setting a performance budget (default 70)." 12 | strategy: 13 | description: "Strategy to use when analyzing the page (mobile/desktop)." 14 | key: 15 | description: "A PageSpeed Insights API key" 16 | runs: 17 | using: "node12" 18 | main: "index.js" 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const core = require("@actions/core"); 2 | const psi = require("psi"); 3 | 4 | const run = async () => { 5 | try { 6 | const url = core.getInput("url"); 7 | if (!url) { 8 | core.setFailed("Url is required to run Page Speed Insights."); 9 | return; 10 | } 11 | 12 | const key = core.getInput('key'); 13 | 14 | const threshold = Number(core.getInput("threshold")) || 70; 15 | const strategy = core.getInput("strategy") || "mobile"; 16 | // Output a formatted report to the terminal 17 | console.log(`Running Page Speed Insights for ${url}`); 18 | await psi.output(url, { 19 | ...(key ? {key} : undefined), 20 | ...(key ? undefined : {nokey: "true"}), 21 | strategy, 22 | format: "cli", 23 | threshold 24 | }); 25 | } catch (error) { 26 | core.setFailed(error.message); 27 | } 28 | }; 29 | 30 | run(); 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Page Speed Insights — A GitHub Action 🏎 2 | 3 | This action utilizes [Google's Page Speed Insights](https://developers.google.com/speed/docs/insights/v5/about) to generate a report on your website's performance 4 | 5 |
