mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-24 19:04:08 +01:00
155 lines
4.4 KiB
YAML
155 lines
4.4 KiB
YAML
name: 'CI'
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- '**'
|
|
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PUBLIC_TYPEKIT_ID: ${{ secrets.GATSBY_TYPEKIT_ID }}
|
|
PUBLIC_MAPBOX_ACCESS_TOKEN: ${{ secrets.GATSBY_MAPBOX_ACCESS_TOKEN }}
|
|
PUBLIC_UMAMI_SCRIPT_URL: ${{ secrets.GATSBY_UMAMI_SCRIPT_URL }}
|
|
PUBLIC_UMAMI_WEBSITE_ID: ${{ secrets.GATSBY_UMAMI_WEBSITE_ID }}
|
|
PUBLIC_INFURA_ID: ${{ secrets.GATSBY_INFURA_ID }}
|
|
PUBLIC_WALLETCONNECT_ID: ${{ secrets.GATSBY_WALLETCONNECT_ID }}
|
|
PUBLIC_WEB3_API_URL: ${{ secrets.PUBLIC_WEB3_API_URL }}
|
|
|
|
jobs:
|
|
lint:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-14]
|
|
node: ['20']
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node }}
|
|
cache: 'npm'
|
|
- run: npm ci
|
|
- run: npm run lint
|
|
|
|
typecheck:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-14]
|
|
node: ['20']
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node }}
|
|
cache: 'npm'
|
|
- run: npm ci
|
|
- run: npm run prebuild
|
|
- run: npm run typecheck
|
|
|
|
test-unit:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-14]
|
|
node: ['20']
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node }}
|
|
cache: 'npm'
|
|
- run: npm ci
|
|
- run: npm run test:unit
|
|
- uses: actions/upload-artifact@v4
|
|
if: matrix.os == 'ubuntu-latest' && matrix.node == '20'
|
|
with:
|
|
name: coverage-${{ matrix.os }}-${{ matrix.node }}
|
|
path: coverage/
|
|
|
|
test-e2e:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest]
|
|
node: ['20']
|
|
runs-on: ${{ matrix.os }}
|
|
timeout-minutes: 60
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node }}
|
|
cache: 'npm'
|
|
- run: npm ci
|
|
- run: npx playwright install --with-deps
|
|
- run: npm run test:e2e
|
|
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, macos-14]
|
|
node: ['20']
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node }}
|
|
cache: 'npm'
|
|
- name: Cache Astro build output
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ github.workspace }}/.astro
|
|
key: ${{ matrix.os }}-${{ matrix.node }}-astro-build-${{ hashFiles('content/**/*.jpg', 'content/**/*.png') }}
|
|
restore-keys: ${{ matrix.os }}-${{ matrix.node }}-astro-build-
|
|
- run: npm ci
|
|
- run: NODE_OPTIONS="--max-old-space-size=4096" npm run build
|
|
- name: Zip artifact for deployment
|
|
if: github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest' && matrix.node == '20'
|
|
run: zip dist.zip ./dist -r
|
|
- uses: actions/upload-artifact@v4
|
|
if: github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest' && matrix.node == '20'
|
|
with:
|
|
name: dist-${{ matrix.os }}-${{ matrix.node }}
|
|
path: dist.zip
|
|
|
|
coverage:
|
|
runs-on: ubuntu-latest
|
|
needs: [test-unit]
|
|
if: ${{ success() && github.actor != 'dependabot[bot]' }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: coverage-ubuntu-latest-20
|
|
- uses: paambaati/codeclimate-action@v5.0.0
|
|
env:
|
|
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
|
|
|
deploy:
|
|
needs: [lint, typecheck, test-unit, test-e2e, build]
|
|
if: success() && github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist-ubuntu-latest-20
|
|
- name: unzip artifact
|
|
run: unzip dist.zip
|
|
- name: Deploy to S3
|
|
run: npm run deploy:s3
|
|
env:
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
|