1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-16 17:43:14 +02:00
blog/.github/workflows/ci.yml

103 lines
2.6 KiB
YAML
Raw Normal View History

2021-01-30 18:46:33 +01:00
name: 'CI'
on:
push:
branches:
- main
pull_request:
branches:
- '**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '15'
- 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
- run: npm test
- uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage/
coverage:
runs-on: ubuntu-latest
needs: [test]
if: ${{ success() && github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: coverage
2021-01-30 18:46:33 +01:00
- uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '15'
- 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 Cache Folder
uses: actions/cache@v1
with:
path: .cache
key: ${{ runner.os }}-cache-gatsby
2021-01-30 21:07:49 +01:00
restore-keys: ${{ runner.os }}-cache-gatsby
2021-01-30 18:46:33 +01:00
- name: Cache Gatsby Public Folder
uses: actions/cache@v1
with:
path: public/
key: ${{ runner.os }}-public-gatsby
2021-01-30 21:07:49 +01:00
restore-keys: ${{ runner.os }}-public-gatsby
2021-01-30 18:46:33 +01:00
- run: npm ci
- run: npm run build
2021-01-30 20:07:22 +01:00
env:
GATSBY_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2021-01-30 21:07:49 +01:00
GATSBY_MAPBOX_ACCESS_TOKEN: ${{ secrets.GATSBY_MAPBOX_ACCESS_TOKEN }}
- uses: actions/upload-artifact@v1
if: github.ref == 'refs/heads/main'
with:
name: public
path: public
deploy:
needs: build
if: success() && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v1
with:
name: public
2021-01-30 21:44:40 +01:00
- run: npm run deploy
2021-01-30 21:07:49 +01:00
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2021-03-01 03:17:17 +01:00
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}