generated from UCLALibrary/nuxt3-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (124 loc) · 6.37 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Run CI Suite
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.ref_name=='main' && github.sha || github.ref_name }} # Cancel runs for previous version of PR, but not main (after merge). For hacked ternary, see https://github.com/actions/runner/issues/409#issuecomment-727565588
cancel-in-progress: true
jobs:
eslint:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: ./.github/workflows/setup-workspace
- run: pnpm run lint
- uses: EndBug/add-and-commit@v9
with:
message: "chore: linter autofixes"
default_author: github_actions
percy-instructions:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Comment with percy instructions
uses: bubkoo/auto-comment@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pullRequestOpened: >
# Percy Screenshots
In order to conserve our percy screenshot allowance, percy is not configured to run automatically. Please make sure the PR is ready and all other checks are passing, then start it manually:
1. Visit https://github.com/UCLALibrary/ftva-website-nuxt/actions/workflows/percy.yml
2. Click the 'Run workflow' button in the blue bar.
3. Select the correct branch for this PR and click 'Run workflow' again to confirm.
nuxt:
name: Nuxt build / Cypress tests / Netlify deploy
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/setup-workspace
- name: Set deployment date
id: set-deploy-date
run: echo "DEPLOY_DATE=$(date '+%Y-%m-%d %H:%M:%S %Z')" >> $GITHUB_ENV
- name: Cache built static site
uses: actions/cache@v3
id: cache-nuxt3
with:
path: .output/public
key: nuxt3-site-${{ github.sha }}
- name: Sets env vars for PR preview
run: |
echo "ES_ALIAS=${{secrets.ES_ALIAS_TEST}}-deploy-preview-${{github.event.pull_request.number}}" >> $GITHUB_ENV
if: github.ref_name!='main'
- name: Sets env vars for main merge
run: |
echo "ES_ALIAS=${{secrets.ES_ALIAS_TEST}}" >> $GITHUB_ENV
if: github.ref_name=='main'
- run: pnpm run generate
if: steps.cache-nuxt3.outputs.cache-hit != 'true'
env:
CRAFT_ENDPOINT: ${{ secrets.CRAFT_ENDPOINT_TEST }}
S3_BUCKET: "https://static.library.ucla.edu/"
SITEMAP_HOST: "https://test-ftva.library.ucla.edu"
ES_URL: ${{ secrets.ES_URL }}
ESApiKey: ${{ secrets.ESApiKey }}
ES_READ_KEY: ${{ secrets.ES_READ_KEY_TEST }}
ES_WRITE_KEY: ${{ secrets.ES_WRITE_KEY_TEST }}
ES_ALIAS: ${{ env.ES_ALIAS }}
ES_INDEX_PREFIX: ${{secrets.ES_INDEX_PREFIX_TEST}}
- name: Deploy to Netlify (preview)
if: github.ref_name!='main'
uses: nwtgck/[email protected] #
with:
production-deploy: false
deploy-message: |
Deploy preview for PR #${{ github.event.pull_request.number }}: Date: ${{ env.DEPLOY_DATE }}
Commit ${{ github.event.pull_request.head.sha }} - https://github.com/UCLALibrary/library-website-nuxt/commit/${{ github.event.pull_request.head.sha }}
Pull Request: https://github.com/UCLALibrary/library-website-nuxt/pull/${{ github.event.pull_request.number }}
alias: deploy-preview-${{ github.event.pull_request.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
overwrites-pull-request-comment: true
publish-dir: .output/public
fails-without-credentials: true
github-deployment-environment: ${{ github.event_name }}-${{ github.event.number }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_TEST_FTVA_SITE_ID }}
# Install Cypress binary explicitly to ensure it's available
- name: Install Cypress
run: npx cypress install
- uses: cypress-io/github-action@v3
with:
start: pnpm dlx serve .output/public
install: false # Skip automatic install
wait-on: http://127.0.0.1:3000
wait-on-timeout: 110
env:
CRAFT_ENDPOINT: ${{ secrets.CRAFT_ENDPOINT_TEST }}
S3_BUCKET: "https://static.library.ucla.edu/"
SITEMAP_HOST: "https://test-ftva.library.ucla.edu"
ES_URL: ${{ secrets.ES_URL }}
ESApiKey: ${{ secrets.ESApiKey }}
ES_READ_KEY: ${{ secrets.ES_READ_KEY_TEST }}
ES_WRITE_KEY: ${{ secrets.ES_WRITE_KEY_TEST }}
ES_INDEX_PREFIX: ${{secrets.ES_INDEX_PREFIX_TEST}}
- name: Deploy to Netlify (test)
if: github.ref_name=='main'
uses: nwtgck/actions-netlify@v2 #
with:
production-deploy: true
deploy-message: "Deploy to test on merge to main Date: ${{ env.DEPLOY_DATE }} for commit ${{ github.sha }}: https://github.com/UCLALibrary/library-website-nuxt/commit/${{ github.sha }}"
github-token: ${{ secrets.GITHUB_TOKEN }}
publish-dir: .output/public
fails-without-credentials: true
github-deployment-environment: testing
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_TEST_FTVA_SITE_ID }}