mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-11-15 09:35:17 +01:00
91 lines
2.1 KiB
YAML
91 lines
2.1 KiB
YAML
name: 'CI/CD Pipeline'
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- '**'
|
|
schedule:
|
|
- cron: '0 22 * * *'
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '14'
|
|
|
|
- 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@v2
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '14'
|
|
|
|
- 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/main'
|
|
with:
|
|
name: public
|
|
path: public
|
|
|
|
deploy:
|
|
needs: build
|
|
if: success() && (github.event_name == 'pull_request' || github.ref == 'refs/heads/main')
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- 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 }}
|