Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
feat: extracted analyze step to its own workflow
Browse files Browse the repository at this point in the history
/spent 15m
  • Loading branch information
nico-i committed Feb 4, 2024
1 parent 362330f commit 6863be6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 36 deletions.
32 changes: 9 additions & 23 deletions .github/workflows/gatsby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,14 @@ jobs:
analyze:
needs: deploy
runs-on: ubuntu-latest
env:
SITE_URL: ${{ vars.SITE_URL }}
PSI_STRAT: ${{ vars.PSI_STRAT }}
PSI_DIR: ${{ vars.PSI_DIR }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Run PSI-SVG
run: |
mkdir -p $PSI_DIR
npx psi-svg $SITE_URL $PSI_DIR/psi.svg --strategy=$PSI_STRAT
- name: Commit and push analysis svg
- name: Trigger Analysis Workflow
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.WEBHOOK_PAT }}
run: |
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
git add $PSI_DIR/psi.svg
git commit -m "chore(deployment): update page speed insights svg [skip ci]"
git push
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${PERSONAL_ACCESS_TOKEN}" \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{"event_type": "analyze-site-event"}'
34 changes: 34 additions & 0 deletions .github/workflows/psi-svg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Analyze Site Performance and Generate SVG

on:
repository_dispatch:
types: [analyze-site-event]

jobs:
analyze:
runs-on: ubuntu-latest
env:
SITE_URL: ${{ vars.SITE_URL }}
PSI_STRAT: ${{ vars.PSI_STRAT }}
PSI_DIR: ${{ vars.PSI_DIR }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Run PSI-SVG
run: |
mkdir -p $PSI_DIR
npx psi-svg $SITE_URL $PSI_DIR/psi.svg --strategy=$PSI_STRAT
- name: Commit and push analysis svg
run: |
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
git add $PSI_DIR/psi.svg
git commit -m "chore(deployment): update page speed insights svg [skip ci]"
git push
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ Furthermore, an effort was made to facilitate the generation of time tracking re

All that's necessary to get started is to configure a data source and implement the desired design.

## Features

### Automatic PageSpeed Insights

The repository is configured to automatically run a PageSpeed Insights audit using the [psi-svg](https://www.npmjs.com/package/psi-svg) package.

After a successful deployment of this website to gh-pages via the [configured workflow](./.github/workflows//gatsby.yml) , the `analyze` job of action generates the `psi.svg`. It displays the current PageSpeed Insights scores. The SVG is uploaded to the output directory configured by the [`PSI_DIR`](https://github.com/nico-i/ssg-starter/settings/variables/actions) environment variable.

This is the `psi.svg` of the latest deployment of this starter:

<br />

![PageSpeed Insights](./docs/svg/psi.svg)

## SSG Framework

My main criteria for selecting a static site generator (from here on referred to as IT) are:
Expand Down Expand Up @@ -63,16 +77,3 @@ The reasons for this decision are:
- [npm trends: Astro vs Gatsby](https://npmtrends.com/astro-vs-gatsby)
- Astro seems to be gaining traction and Gatsby seems to slowly be losing some of its popularity.

## Features

### Automatic PageSpeed Insights

The repository is configured to automatically run a PageSpeed Insights audit using the [psi-svg](https://www.npmjs.com/package/psi-svg) package.

After a successful deployment of this website to gh-pages via the [configured workflow](./.github/workflows//gatsby.yml) , the `analyze` job of action generates the `psi.svg`. It displays the current PageSpeed Insights scores. The SVG is uploaded to the output directory configured by the [`PSI_DIR`](https://github.com/nico-i/ssg-starter/settings/variables/actions) environment variable.

This is the `psi.svg` of the latest deployment of this starter:

<br />

![PageSpeed Insights](./docs/svg/psi.svg)

0 comments on commit 6863be6

Please sign in to comment.