1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-06-30 21:51:50 +02:00

Merge pull request #189 from kremalicious/feature/github

Feature/GitHub
This commit is contained in:
Matthias Kretschmann 2019-11-26 11:00:52 +01:00 committed by GitHub
commit 5253247e5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 89 additions and 87 deletions

View File

@ -10,7 +10,6 @@ LICENSE
.vscode .vscode
public public
.cache .cache
.travis.yml
package-lock.json package-lock.json
README.md README.md
coverage coverage

82
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,82 @@
name: 'CI/CD Pipeline'
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '13.x'
- 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@v1
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '13.x'
- 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/master'
with:
name: public
path: public
deploy:
needs: build
if: success() && (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
- 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 }}

View File

@ -1,39 +0,0 @@
name: Test
on: [push]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['10', '12', '13']
steps:
- 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: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-${{ matrix.node-version }}-
- name: Cache Gatsby build output
uses: actions/cache@v1
with:
path: public
key: ${{ runner.os }}-${{ matrix.node-version }}-public
- run: npm ci
- run: npm test
- run: npm run build
env:
CI: true
GATSBY_GITHUB_TOKEN: ${{ secrets.GATSBY_GITHUB_TOKEN }}

View File

@ -1,40 +0,0 @@
dist: xenial
language: node_js
node_js:
- '12'
cache:
npm: true
directories:
- public
before_install:
- sudo apt-get -qq update
- sudo apt-get install python3-pip
- sudo -H pip3 install --upgrade pip
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- './cc-test-reporter before-build'
script:
- npm test
- './cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT'
- npm run build
after_success:
- pip install --user awscli
- export PATH=$PATH:$HOME/.local/bin
- npm run deploy
- npm run lh -- https://beta.matthiaskretschmann.com
notifications:
email: false
slack:
template:
- '%{branch} *%{result}* build (<%{build_url}|#%{build_number}>) for <%{compare_url}|%{commit}>'
- 'Execution time: *%{duration}*'
- 'Message: %{message}'
rooms:
- secure: r6kVJw3zS4raTXgeBEYZYO/5YawnLoi1vO4zG3obhcNFRLm9FxlzuXfulFhjQA4viPQUW07m5UGud4bPTrDIAE35GUcLRlyisH/odahgsrmqLrBvz9CB+/V5WrEsCGpE9G3I/y5JGSRavjs+5qfVqJZaAI9Ox7bCcw+Msa5r/p7/yJw5di4EzgNLFWQswyio0zeOdjtCYgqpngWtLGpn0ksSwqNyqp/kntoHSz4nDdO/6GWS1q5K9mOfGMXr/wwiYuQrgDPpygRWETy9F8qh9yH2cseJmCZaXvSTSU1L9yV01qrBP5zDTTM2jPUGMQKY4JBoxFtU29G1BLWGAgMW9ymKe9V+f8FgbirZ+O1Vp87QAZPJXx5kO+pgqBtGewoYfp0k9HJ5xQAhr83l82w8BAEHVS3G/Y7cKKK9QNH9Z6gpdx6Y3s9YkpGqkv79MRvZo0tJV+XTOldCCfUFVxXXuZofuswWGUgt2h9qNoFY+AZc0G1TV/XVDHbDm32JNiGkuk+uO83HT9VI7G5PRWNcD8kP7ZS6XThiU2qOGr4OPGggmpFpJ7Yqc3LNFOjhFunKSzGOrZrc0GLZAbAR7qHkWNpiqQQ/RSpfnXfbPlAIJY6w5Vuzh9KhIIPkbWdP89Bc2Kw+W+ACFjStO7s298/8dty44EvJ2TS9CCjOhYtgaxk=

View File

@ -8,7 +8,7 @@
<a href="https://matthiaskretschmann.com">matthiaskretschmann.com</a> <a href="https://matthiaskretschmann.com">matthiaskretschmann.com</a>
</p> </p>
<p align="center"> <p align="center">
<a href="https://travis-ci.com/kremalicious/portfolio"><img src="https://travis-ci.com/kremalicious/portfolio.svg?branch=master" /></a> <a href="https://github.com/kremalicious/portfolio/actions"><img src="https://github.com/kremalicious/portfolio/.github/workflows/ci.yml/badge.svg" /></a>
<a href="https://codeclimate.com/github/kremalicious/portfolio/maintainability"><img src="https://api.codeclimate.com/v1/badges/8f561ec93e0f8c6b15d9/maintainability" /></a> <a href="https://codeclimate.com/github/kremalicious/portfolio/maintainability"><img src="https://api.codeclimate.com/v1/badges/8f561ec93e0f8c6b15d9/maintainability" /></a>
<a href="https://codeclimate.com/github/kremalicious/portfolio/test_coverage"><img src="https://api.codeclimate.com/v1/badges/8f561ec93e0f8c6b15d9/test_coverage" /></a> <a href="https://codeclimate.com/github/kremalicious/portfolio/test_coverage"><img src="https://api.codeclimate.com/v1/badges/8f561ec93e0f8c6b15d9/test_coverage" /></a>
<a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/kremalicious/portfolio.svg" /></a> <a href="https://greenkeeper.io/"><img src="https://badges.greenkeeper.io/kremalicious/portfolio.svg" /></a>
@ -220,7 +220,7 @@ SLUG-03.png
## 🚚 Deployment ## 🚚 Deployment
Automatic deployments are triggered upon successful tests & builds on Travis: Automatic deployments are triggered upon successful tests & builds via GitHub Actions:
- push to `master` initiates a live deployment - push to `master` initiates a live deployment
- any Pull Request, and subsequent pushes to it, initiates a beta deployment - any Pull Request, and subsequent pushes to it, initiates a beta deployment
@ -231,7 +231,7 @@ The deploy command simply calls the [`scripts/deploy.sh`](scripts/deploy.sh) scr
npm run deploy npm run deploy
``` ```
Upon live deployment, deploy script also purges the Cloudflare cache, and pings search engines. Travis requires the following environment variables to be setup for successful deployments: Upon live deployment, deploy script also purges the Cloudflare cache, and pings search engines. GitHub requires the following environment variables to be setup for successful deployments in the repository secrets:
- `AWS_ACCESS_KEY_ID` - `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY` - `AWS_SECRET_ACCESS_KEY`
@ -242,7 +242,7 @@ Upon live deployment, deploy script also purges the Cloudflare cache, and pings
## 🏛 Licenses ## 🏛 Licenses
**© Copyright 2018 Matthias Kretschmann** **© Copyright 2019 Matthias Kretschmann**
All images and projects are plain ol' copyright, most displayed projects are subject to the copyright of their respective owners. All images and projects are plain ol' copyright, most displayed projects are subject to the copyright of their respective owners.

View File

@ -63,18 +63,18 @@ function ping {
## ##
## check for pull request against master ## check for pull request against master
## ##
if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
s3sync $AWS_S3_BUCKET_BETA s3sync $AWS_S3_BUCKET_BETA
## ##
## check for master push which is no pull request ## check for master push which is no pull request
## ##
elif [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] || [ "$TRAVIS" != true ]; then elif [ "$GITHUB_REF" == "refs/heads/master" ]; then
s3sync $AWS_S3_BUCKET s3sync $AWS_S3_BUCKET
purge # purge
ping ping