2019-11-26 01:05:58 +01:00
|
|
|
name: 'CI/CD Pipeline'
|
2019-11-13 18:43:58 +01:00
|
|
|
|
2019-12-07 15:16:07 +01:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- '**'
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- '**'
|
|
|
|
schedule:
|
|
|
|
- cron: '0 22 * * *'
|
2019-11-13 18:43:58 +01:00
|
|
|
|
|
|
|
jobs:
|
2019-11-14 01:22:14 +01:00
|
|
|
test:
|
2019-11-13 18:43:58 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
2019-11-26 01:05:58 +01:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
|
2019-11-26 01:20:37 +01:00
|
|
|
- name: Setup Node.js
|
2019-11-26 01:05:58 +01:00
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
2020-11-13 01:05:26 +01:00
|
|
|
node-version: '15.x'
|
2019-11-26 01:05:58 +01:00
|
|
|
|
|
|
|
- name: Cache node modules
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: ~/.npm
|
2019-11-26 01:20:37 +01:00
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: ${{ runner.os }}-node-
|
2019-11-26 01:05:58 +01:00
|
|
|
|
|
|
|
- run: npm ci
|
2019-11-26 02:18:54 +01:00
|
|
|
|
|
|
|
- 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 }}
|
2019-11-26 01:05:58 +01:00
|
|
|
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
2019-11-13 18:43:58 +01:00
|
|
|
steps:
|
2019-11-13 18:53:31 +01:00
|
|
|
- uses: actions/checkout@v1
|
2019-11-18 23:02:57 +01:00
|
|
|
|
2019-11-26 01:20:37 +01:00
|
|
|
- name: Setup Node.js
|
2019-11-13 18:53:31 +01:00
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
2020-11-13 01:05:26 +01:00
|
|
|
node-version: '15.x'
|
2019-11-13 18:53:31 +01:00
|
|
|
|
|
|
|
- name: Cache node modules
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
2019-11-14 01:02:49 +01:00
|
|
|
path: ~/.npm
|
2019-11-26 01:20:37 +01:00
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: ${{ runner.os }}-node-
|
2019-11-14 01:02:49 +01:00
|
|
|
|
|
|
|
- name: Cache Gatsby build output
|
|
|
|
uses: actions/cache@v1
|
|
|
|
with:
|
|
|
|
path: public
|
2019-11-26 01:20:37 +01:00
|
|
|
key: ${{ runner.os }}-public
|
2019-11-13 18:53:31 +01:00
|
|
|
|
2019-11-18 23:02:57 +01:00
|
|
|
- run: npm ci
|
|
|
|
- run: npm run build
|
2019-11-13 18:53:31 +01:00
|
|
|
env:
|
|
|
|
GATSBY_GITHUB_TOKEN: ${{ secrets.GATSBY_GITHUB_TOKEN }}
|
2019-11-26 01:20:37 +01:00
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v1
|
2020-07-02 19:32:37 +02:00
|
|
|
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
|
2019-11-26 01:20:37 +01:00
|
|
|
with:
|
|
|
|
name: public
|
|
|
|
path: public
|
2019-11-26 01:45:27 +01:00
|
|
|
|
|
|
|
deploy:
|
|
|
|
needs: build
|
2020-07-02 19:32:37 +02:00
|
|
|
if: success() && (github.event_name == 'pull_request' || github.ref == 'refs/heads/main')
|
2019-11-26 01:45:27 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- uses: actions/download-artifact@v1
|
|
|
|
with:
|
|
|
|
name: public
|
2019-11-26 02:18:54 +01:00
|
|
|
- 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 }}
|
2019-11-12 00:05:54 +01:00
|
|
|
|
|
|
|
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
|
2020-07-02 19:32:37 +02:00
|
|
|
if: success() && github.ref == 'refs/heads/main'
|
2019-11-12 00:05:54 +01:00
|
|
|
uses: treosh/lighthouse-ci-action@v2
|
|
|
|
with:
|
|
|
|
urls: 'https://matthiaskretschmann.com'
|
|
|
|
configPath: './.github/workflows/lighthouserc.json'
|
|
|
|
temporaryPublicStorage: 'true'
|