1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-07-01 06:01:48 +02:00
portfolio/.github/workflows/ci.yml

114 lines
2.9 KiB
YAML

name: 'CI/CD Pipeline'
on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
schedule:
- cron: '0 22 * * *'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '13.x'
- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- run: npm ci
- name: Run tests & publish code coverage
uses: paambaati/codeclimate-action@v2.3.0
with:
coverageCommand: npm test
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '13.x'
- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Cache Gatsby build output
uses: actions/cache@v1
with:
path: public
key: ${{ runner.os }}-public
- run: npm ci
- run: npm run build
env:
GATSBY_GITHUB_TOKEN: ${{ secrets.GATSBY_GITHUB_TOKEN }}
- uses: actions/upload-artifact@v1
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
with:
name: public
path: public
deploy:
needs: build
if: success() && (github.event_name == 'pull_request' || github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/download-artifact@v1
with:
name: public
- name: Deploy to S3
run: ./scripts/deploy.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
lighthouse:
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Audit Beta using Lighthouse
if: success() && github.event_name == 'pull_request'
uses: treosh/lighthouse-ci-action@v2
with:
urls: 'https://beta.matthiaskretschmann.com'
configPath: './.github/workflows/lighthouserc.json'
temporaryPublicStorage: 'true'
- name: Audit Live using Lighthouse
if: success() && github.ref == 'refs/heads/master'
uses: treosh/lighthouse-ci-action@v2
with:
urls: 'https://matthiaskretschmann.com'
configPath: './.github/workflows/lighthouserc.json'
temporaryPublicStorage: 'true'