Last active
June 9, 2023 19:04
-
-
Save paulgibbs/bc16f2f8c51c271d897d61c362bc7d2a to your computer and use it in GitHub Desktop.
Indigo Tree LHCI
This file contains hidden or 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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow | |
name: Run Lighthouse checks | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "12 2 * * *" | |
jobs: | |
lighthouseci: | |
name: Lighthouse | |
runs-on: ubuntu-latest | |
steps: | |
- name: Delay execution on branch push | |
if: github.event_name == 'push' | |
run: sleep 300 # Sleep for 5 minutes (300 seconds) | |
- uses: actions/checkout@v3 | |
- name: Setup Node JS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
cache: "npm" | |
- name: Install Dependencies | |
run: npm install -g @lhci/cli | |
- name: Configure Lighthouse Settings (for scheduled and manual runs) | |
if: github.event_name != 'push' | |
run: | | |
commit_hash=${{ github.sha }} | |
trimmed_hash=${commit_hash:0:-5} | |
random_chars=$(date +%s%N | sha256sum | base64 | head -c 4) | |
modified_hash="${trimmed_hash}-${random_chars}" | |
echo "LHCI_BUILD_CONTEXT__CURRENT_HASH=${modified_hash}" >> $GITHUB_ENV | |
echo "LHCI_BUILD_CONTEXT__COMMIT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")" >> $GITHUB_ENV | |
echo "LHCI_BUILD_CONTEXT__COMMIT_MESSAGE='Daily run'" >> $GITHUB_ENV | |
echo "LHCI_BUILD_CONTEXT__AUTHOR='LHCI Automation <[email protected]>'" >> $GITHUB_ENV | |
echo "[email protected]" >> $GITHUB_ENV | |
- name: Run Lighthouse CI | |
run: lhci autorun --collect.url="https://example.com" --collect.url="https://example.com/about-us" --upload.token="$ITD_LHCI_TOKEN" | |
env: | |
LHCI_SERVER_BASE_URL: ${{ secrets.LHCI_SERVER_BASE_URL }} | |
LHCI_BASIC_AUTH__USERNAME: ${{ secrets.LHCI_BASIC_AUTH__USERNAME }} | |
LHCI_BASIC_AUTH__PASSWORD: ${{ secrets.LHCI_BASIC_AUTH__PASSWORD }} | |
ITD_LHCI_TOKEN: ${{ secrets.ITD_LHCI_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace
https://example.com
with the website to test. As I show in this example, if the--collect.url
appears more than once, then it will check all those specific pages.