diff --git a/.dockerignore b/.dockerignore index 7b49a06..ae12b32 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,7 +10,6 @@ LICENSE .vscode public .cache -.travis.yml package-lock.json README.md coverage diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7d662b1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 90d42cd..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -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 }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 393b77b..0000000 --- a/.travis.yml +++ /dev/null @@ -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= diff --git a/README.md b/README.md index 9d1219a..cfc66ea 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ matthiaskretschmann.com

- + @@ -220,7 +220,7 @@ SLUG-03.png ## 🚚 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 - 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 ``` -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_SECRET_ACCESS_KEY` @@ -242,7 +242,7 @@ Upon live deployment, deploy script also purges the Cloudflare cache, and pings ## 🏛 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. diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 2170ca5..60871ad 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -63,18 +63,18 @@ function ping { ## ## 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 ## ## 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 - purge + # purge ping