update scripts for Hacker News #369
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
audit-build-test-deploy: | |
name: 🔧 Audit, build, test, deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🛎️ Checkout repo | |
uses: actions/checkout@v4 | |
- name: 🖥️ Setup Node.js | |
# https://github.com/marketplace/actions/setup-node-js-environment | |
uses: actions/setup-node@v4 | |
with: | |
# https://github.com/nodejs/Release/blob/main/CODENAMES.md | |
node-version: lts/Iron | |
- run: npm ci --include dev --include prod | |
- name: 🛡️ Audit security | |
continue-on-error: true | |
run: npm audit --audit-level=moderate | |
- name: 🔧 Build website | |
env: | |
CLOUDINARY: ${{ secrets.CLOUDINARY }} | |
DEBUG: Eleventy:ErrorHandler,eleventy-plugin-text-to-speech/*,-eleventy-plugin-text-to-speech/transforms | |
DOMAIN: ${{ secrets.DOMAIN }} | |
GCP_CREDENTIALS_JSON: ${{ secrets.GCP_CREDENTIALS_JSON }} | |
NODE_ENV: production | |
STRIPE_LIVE: ${{ secrets.STRIPE_LIVE }} | |
TELEGRAM: ${{ secrets.TELEGRAM }} | |
WEBMENTION_IO_TOKEN: ${{ secrets.WEBMENTION_IO_TOKEN }} | |
WEBPAGETEST: ${{ secrets.WEBPAGETEST }} | |
run: npm run build | |
- name: 🔍 Test website | |
env: | |
STRIPE_TEST: ${{ secrets.STRIPE_TEST }} | |
run: npm run test | |
- name: 🌐 Deploy to Cloudflare Pages | |
# https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/ | |
# https://github.com/marketplace/actions/cloudflare-pages-github-action | |
uses: cloudflare/pages-action@1 | |
with: | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
projectName: personal-website | |
directory: _site | |
# Optional: Enable this if you want to have GitHub Deployments triggered | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
# wpt: | |
# name: Audit website with WebPageTest API | |
# needs: [audit-build-test-deploy] | |
# if: ${{ github.event_name == 'pull_request' }} | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: 🛎️ Checkout repo | |
# uses: actions/checkout@v4 | |
# - name: Wait for a successfull Deploy Preview on Netlify | |
# # https://github.com/JakePartusch/wait-for-netlify-action | |
# uses: jakepartusch/wait-for-netlify-action@v1 | |
# id: netlify | |
# with: | |
# site_name: ${{ secrets.SITE_NAME }} | |
# max_timeout: 60 | |
# - name: Audit pages with WebPageTest (home/contact, mobile) | |
# # https://github.com/WPO-Foundation/webpagetest-github-action | |
# uses: WPO-Foundation/webpagetest-github-action@v1.1.2 | |
# with: | |
# apiKey: ${{ secrets.WPT_API_KEY }} | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# label: 'home-contact-mobile' | |
# urls: | | |
# ${{ steps.netlify.outputs.url }}/ | |
# ${{ steps.netlify.outputs.url }}/contact/ | |
# budget: 'wpt-budget.json' | |
# wptOptions: 'wpt-options-mobile.json' | |
# - name: Audit pages with WebPageTest (home/contact, desktop) | |
# uses: WPO-Foundation/webpagetest-github-action@v1.1.2 | |
# with: | |
# apiKey: ${{ secrets.WPT_API_KEY }} | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# label: 'home-contact-desktop' | |
# urls: | | |
# ${{ steps.netlify.outputs.url }}/ | |
# ${{ steps.netlify.outputs.url }}/contact/ | |
# budget: 'wpt-budget.json' | |
# wptOptions: 'wpt-options-desktop.json' | |
# - name: Audit page with WebPageTest (article, desktop) | |
# uses: WPO-Foundation/webpagetest-github-action@v1.1.2 | |
# env: | |
# ARTICLE_SLUG: 12-years-of-fires-in-sardinia | |
# with: | |
# apiKey: ${{ secrets.WPT_API_KEY }} | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# label: 'article-desktop' | |
# urls: | | |
# ${{ steps.netlify.outputs.url }}/posts/${{ env.ARTICLE_SLUG }} | |
# budget: 'wpt-budget-article-desktop.json' | |
# wptOptions: 'wpt-options-desktop.json' | |
# TODO: wait for successful Deploy Preview on Cloudflare Pages | |
# audit: | |
# name: Audit website with Lighthouse CI | |
# needs: [build-and-test] | |
# if: ${{ github.event_name == 'pull_request' }} | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v4 | |
# - name: Wait for a successful Deploy Preview on Netlify | |
# uses: jakepartusch/wait-for-netlify-action@v1 | |
# id: netlify | |
# with: | |
# site_name: ${{ secrets.SITE_NAME }} | |
# max_timeout: 60 | |
# - name: 🌐 Notify Telegram chat about Netlify deployment | |
# uses: appleboy/telegram-action@v0.1.1 | |
# with: | |
# to: ${{ fromJSON(secrets.TELEGRAM).chat_id }} | |
# token: ${{ fromJSON(secrets.TELEGRAM).token }} | |
# format: html | |
# disable_web_page_preview: true | |
# # https://core.telegram.org/bots/api#formatting-options | |
# message: | | |
# <b>🌐 New deploy preview on Netlify</b> | |
# The website <code>${{ secrets.SITE_NAME }}</code> is <b>live</b> at: | |
# <a href="${{ steps.netlify.outputs.url }}">${{ steps.netlify.outputs.url }}</a> | |
# Repository: <a href="https://github.com/${{ github.repository }}/">${{ github.repository }}</a> | |
# <a href="https://github.com/${{ github.repository }}/commit/${{github.sha}}">Changes</a> in commit <code>${{github.sha}}</code> | |
# - name: Audit contact page with Lighthouse CI (mobile) | |
# uses: treosh/lighthouse-ci-action@v7 | |
# with: | |
# urls: | | |
# ${{ steps.netlify.outputs.url }}/contact/ | |
# configPath: lighthouse/lighthouserc-contact-mobile.js | |
# temporaryPublicStorage: true | |
# uploadArtifacts: true | |
# - name: Audit contact page with Lighthouse CI (desktop) | |
# uses: treosh/lighthouse-ci-action@v7 | |
# with: | |
# urls: | | |
# ${{ steps.netlify.outputs.url }}/contact/ | |
# configPath: lighthouse/lighthouserc-contact-desktop.js | |
# temporaryPublicStorage: true | |
# uploadArtifacts: true | |
# - name: Audit home, blog, project page with Lighthouse CI (desktop) | |
# uses: treosh/lighthouse-ci-action@v7 | |
# env: | |
# ARTICLE_SLUG: 12-years-of-fires-in-sardinia | |
# with: | |
# urls: | | |
# ${{ steps.netlify.outputs.url }}/ | |
# ${{ steps.netlify.outputs.url }}/blog/ | |
# ${{ steps.netlify.outputs.url }}/projects/ | |
# ${{ steps.netlify.outputs.url }}/posts/${{ env.ARTICLE_SLUG }} | |
# configPath: lighthouse/lighthouserc-all-desktop.js | |
# temporaryPublicStorage: true | |
# uploadArtifacts: true |