1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-11-15 09:35:17 +01:00
portfolio/.github/workflows/ci.yml

103 lines
2.3 KiB
YAML
Raw Normal View History

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:
2021-01-30 19:20:15 +01:00
- main
2019-12-07 15:16:07 +01:00
pull_request:
branches:
- '**'
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:
2020-11-13 01:44:39 +01:00
- uses: actions/checkout@v2
2019-11-26 01:05:58 +01:00
2019-11-26 01:20:37 +01:00
- name: Setup Node.js
2021-01-30 19:15:09 +01:00
uses: actions/setup-node@v2
2019-11-26 01:05:58 +01:00
with:
2021-11-28 17:12:27 +01:00
node-version: '16'
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
2021-02-06 13:45:47 +01:00
- run: npm test
2019-11-26 02:18:54 +01:00
- 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
- uses: paambaati/codeclimate-action@v2.7.5
2019-11-26 02:18:54 +01:00
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:
2020-11-13 01:44:39 +01:00
- uses: actions/checkout@v2
2019-11-18 23:02:57 +01:00
2019-11-26 01:20:37 +01:00
- name: Setup Node.js
2021-01-30 19:15:09 +01:00
uses: actions/setup-node@v2
2019-11-13 18:53:31 +01:00
with:
2021-11-28 17:12:27 +01:00
node-version: '16'
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:
2021-02-06 13:45:47 +01:00
GATSBY_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2019-11-26 01:20:37 +01:00
- uses: actions/upload-artifact@v1
2021-02-06 13:45:47 +01:00
if: 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
2021-02-06 13:19:30 +01:00
if: success() && github.ref == 'refs/heads/main'
2019-11-26 01:45:27 +01:00
runs-on: ubuntu-latest
steps:
2020-11-22 00:17:18 +01:00
- uses: actions/checkout@v2
2019-11-26 01:45:27 +01:00
- uses: actions/download-artifact@v1
with:
name: public
2019-11-26 02:18:54 +01:00
- name: Deploy to S3
2021-02-06 13:19:30 +01:00
run: npm run deploy:s3
2019-11-26 02:18:54 +01:00
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2021-02-06 13:45:47 +01:00
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}