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

72 lines
1.6 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-11-26 01:45:27 +01:00
on: [push, pull_request]
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:
2019-11-26 01:20:37 +01:00
node-version: '13.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
- run: npm test
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:
2019-11-26 01:20:37 +01:00
node-version: '13.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
with:
name: public
path: public
2019-11-26 01:45:27 +01:00
deploy:
needs: build
if: 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
- run: ./scripts/deploy.sh