1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-29 07:26:22 +01:00
blog/.github/workflows/ci.yml

99 lines
2.9 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:
2022-09-17 23:08:04 +02:00
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
2021-01-30 18:46:33 +01:00
with:
2022-09-17 23:08:04 +02:00
node-version: '18'
2021-01-30 18:46:33 +01:00
- name: Cache node modules
2022-09-17 23:08:04 +02:00
uses: actions/cache@v3
2021-01-30 18:46:33 +01:00
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Cache Gatsby Cache Folder
2022-09-17 23:08:04 +02:00
uses: actions/cache@v3
2021-01-30 18:46:33 +01:00
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
2022-09-17 23:08:04 +02:00
uses: actions/cache@v3
2021-01-30 18:46:33 +01:00
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:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2021-09-12 23:21:47 +02:00
GATSBY_TYPEKIT_ID: ${{ secrets.GATSBY_TYPEKIT_ID }}
2021-01-30 21:07:49 +01:00
GATSBY_MAPBOX_ACCESS_TOKEN: ${{ secrets.GATSBY_MAPBOX_ACCESS_TOKEN }}
2022-11-17 19:29:27 +01:00
GATSBY_UMAMI_SCRIPT_URL: ${{ secrets.GATSBY_UMAMI_SCRIPT_URL }}
GATSBY_UMAMI_WEBSITE_ID: ${{ secrets.GATSBY_UMAMI_WEBSITE_ID }}
GATSBY_INFURA_ID: ${{ secrets.GATSBY_INFURA_ID }}
- run: npm test
2022-12-03 12:13:28 +01:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GATSBY_TYPEKIT_ID: ${{ secrets.GATSBY_TYPEKIT_ID }}
GATSBY_MAPBOX_ACCESS_TOKEN: ${{ secrets.GATSBY_MAPBOX_ACCESS_TOKEN }}
GATSBY_UMAMI_SCRIPT_URL: ${{ secrets.GATSBY_UMAMI_SCRIPT_URL }}
GATSBY_UMAMI_WEBSITE_ID: ${{ secrets.GATSBY_UMAMI_WEBSITE_ID }}
GATSBY_INFURA_ID: ${{ secrets.GATSBY_INFURA_ID }}
- uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage/
2021-01-30 21:07:49 +01:00
2022-11-08 23:47:01 +01:00
- uses: actions/upload-artifact@v1
2021-01-30 21:07:49 +01:00
if: github.ref == 'refs/heads/main'
with:
name: public
2022-11-08 23:47:01 +01:00
path: public
2021-01-30 21:07:49 +01:00
coverage:
runs-on: ubuntu-latest
needs: [test]
if: ${{ success() && github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: coverage
- uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
2021-01-30 21:07:49 +01:00
deploy:
needs: test
2021-01-30 21:07:49 +01:00
if: success() && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
2022-11-08 23:47:01 +01:00
- uses: actions/checkout@v2
- uses: actions/download-artifact@v1
2021-01-30 21:07:49 +01:00
with:
name: public
2022-11-08 23:47:01 +01:00
- name: Deploy to S3
run: npm run deploy:s3
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 }}