Last active
March 3, 2019 18:28
-
-
Save palkan/a7654f87f9c6dbdb397d39fcb90d253a to your computer and use it in GitHub Desktop.
Parcel + GH pages + S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2.1 | |
workflows: | |
version: 2 | |
build_and_test: | |
jobs: | |
- checkout | |
- yarn_install: | |
requires: | |
- checkout | |
- yarn_build: | |
requires: | |
- yarn_install | |
- gh_deploy: | |
requires: | |
- yarn_build | |
filters: | |
branches: | |
only: master | |
- aws_deploy: | |
requires: | |
- yarn_build | |
filters: | |
branches: | |
only: production | |
executors: | |
node: | |
docker: | |
- image: circleci/node:11.8.0-stretch | |
environment: | |
NODE_ENV: development | |
jobs: | |
checkout: | |
executor: node | |
steps: | |
- restore_cache: | |
keys: | |
- project-source-v1-{{ .Branch }}-{{ .Revision }} | |
- project-source-v1-{{ .Branch }} | |
- project-source-v1 | |
- checkout | |
- save_cache: | |
key: project-source-v1-{{ .Branch }}-{{ .Revision }} | |
paths: | |
- .git | |
- persist_to_workspace: | |
root: . | |
paths: . | |
yarn_install: | |
executor: node | |
steps: | |
- attach_workspace: | |
at: . | |
- restore_cache: | |
keys: | |
- project-npm-v1-{{ "yarn.lock" }} | |
- project-npm-v1 | |
- run: | |
name: Updating Yarn | |
command: | | |
sudo npm i -g yarn@1.13.0 && sudo chmod 777 /usr/local/bin/yarn | |
- run: | |
name: Installing NPM dependencies | |
command: | | |
yarn install | |
- save_cache: | |
key: project-npm-v1-{{ "yarn.lock" }} | |
paths: | |
- node_modules | |
- persist_to_workspace: | |
root: . | |
paths: | |
- node_modules | |
yarn_build: | |
executor: node | |
steps: | |
- attach_workspace: | |
at: . | |
- restore_cache: | |
keys: | |
- project-cache-v1-{{ .Branch }}-{{ .Revision }} | |
- project-cache-v1-{{ .Branch }} | |
- project-cache-v1 | |
- run: | |
name: Yarn build | |
command: yarn build | |
- save_cache: | |
key: project-cache-v1-{{ .Branch }}-{{ .Revision }} | |
paths: | |
- .cache | |
- persist_to_workspace: | |
root: . | |
paths: | |
- dist | |
gh_deploy: | |
executor: node | |
steps: | |
- attach_workspace: | |
at: . | |
- run: | |
name: Configure git | |
command: | | |
git config user.name "$GITHUB_USER_NAME" && \ | |
git config user.email "$GITHUB_USER_EMAIL" | |
- run: | |
name: Add github.com to known_hosts | |
command: mkdir -p ~/.ssh && ssh-keyscan -H github.com > ~/.ssh/known_hosts | |
- add_ssh_keys: | |
fingerprints: | |
- "88:2a:a7:53:79:8e:97:27:07:6d:1f:b7:7d:fb:e0:a1" | |
- run: | |
name: Add CNAME | |
command: echo "${GITHUB_CNAME}" > dist/CNAME | |
- run: | |
name: Deploy to gh-pages | |
command: yarn deploy | |
aws_deploy: | |
executor: node | |
steps: | |
- attach_workspace: | |
at: . | |
- run: | |
name: Install AWS CLI | |
command: | | |
sudo apt-get update && sudo apt-get install -y python-dev && \ | |
sudo curl -O https://bootstrap.pypa.io/get-pip.py && \ | |
sudo python get-pip.py && \ | |
sudo pip install awscli --upgrade | |
- run: aws --version | |
- run: aws s3 ls s3://${S3_BUCKET} | |
- run: | |
name: Deploy to S3 | |
command: | |
aws s3 sync dist/ s3://${S3_BUCKET} --delete | |
- run: | |
name: Update index.html cache control | |
command: | |
aws s3 cp dist/index.html s3://${S3_BUCKET}/index.html --cache-control "max-age=600" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "parce-project", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"devDependencies": { | |
"autoprefixer": "9.4.9", | |
"gh-pages": "2.0.1", | |
"parcel-bundler": "1.11.0", | |
"parcel-plugin-static-files-copy": "2.0.0", | |
"postcss-import": "12.0.1", | |
"postcss-nested": "4.1.2", | |
"postcss-normalize": "7.0.1", | |
"postcss-simple-vars": "5.0.2" | |
}, | |
"scripts": { | |
"dev": "parcel index.html site.webmanifest", | |
"build": "parcel build index.html site.webmanifest", | |
"deploy": "gh-pages -d dist -m \"[ci skip] Updates\"" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment