diff --git a/.env.example b/.env.example index 2a9ec0c..200e8f9 100644 --- a/.env.example +++ b/.env.example @@ -1 +1 @@ -#GITHUB_TOKEN= +#GATSBY_GITHUB_TOKEN= diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2972ffa..1d9c7e9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,9 @@ -name: Node CI +name: Test on: [push] jobs: build: - runs-on: ubuntu-latest strategy: @@ -12,15 +11,31 @@ jobs: node-version: [12.x] steps: - - uses: actions/checkout@v1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: npm install, build, and test - run: | - npm ci - npm test - npm run build --if-present - env: - CI: true + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache node modules + uses: actions/cache@v1 + with: + path: node_modules + key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-build-${{ env.cache-name }}- + ${{ runner.OS }}-build- + ${{ runner.OS }}- + + - name: Install Dependencies + run: | + npm ci + - name: Test + run: | + npm test + - name: Build + run: | + npm run build --if-present + env: + CI: true + GATSBY_GITHUB_TOKEN: ${{ secrets.GATSBY_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 62d9ffb..5055698 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ npm-debug.log* yarn-debug.log* plugins/gatsby-plugin-matomo coverage +.env diff --git a/gatsby-node.js b/gatsby-node.js index 818dfc0..0a4ff71 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -29,7 +29,7 @@ function truncate(n, useWordBoundary) { const gitHubConfig = { headers: { 'User-Agent': 'kremalicious/portfolio', - Authorization: `token ${process.env.GITHUB_TOKEN}` + Authorization: `token ${process.env.GATSBY_GITHUB_TOKEN}` } }