1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-25 03:14:01 +01:00
blog/.github/workflows/ci.yml

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-13]
node: ['18']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
- run: npm run lint
typecheck:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13]
node: ['18']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
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-13]
node: ['18']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- run: npm ci
- run: npm run test:unit
- uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest' && matrix.node == '18'
with:
name: coverage-${{ matrix.os }}-${{ matrix.node }}
path: coverage/
test-e2e:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: ['18']
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
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-13]
node: ['18']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Cache Astro build output
uses: actions/cache@v3
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 == '18'
run: zip dist.zip ./dist -r
- uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest' && matrix.node == '18'
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@v3
- uses: actions/download-artifact@v3
with:
name: coverage-ubuntu-latest-18
- 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@v3
- uses: actions/download-artifact@v3
with:
name: dist-ubuntu-latest-18
- 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 }}