Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:10.15.1
steps:
- checkout
- run:
command: npm ci
- run:
command: make build
- persist_to_workspace:
root: .
paths:
- public

deploy:
docker:
- image: olizilla/ipfs-dns-deploy
environment:
DOMAIN: docs.libp2p.io
BUILD_DIR: build
steps:
- attach_workspace:
at: /tmp/workspace
- run:
name: Pin website, post notification for PRs or update DNS on master
command: |
# Upload build dir to cluster.ipfs.io
hash=$(ipfs-cluster-ctl \
--host /dnsaddr/cluster.ipfs.io \
--basic-auth $CLUSTER_USER:$CLUSTER_PASSWORD \
add --rmin 3 --rmax 3 --name "$DOMAIN" \
--recursive /tmp/workspace/$BUILD_DIR | tail -n1 | cut -d " " -f 2 )

preview_url=https://ipfs.io/ipfs/$hash

echo "Website added to IPFS: $preview_url"

if [ ! -z "$CIRCLE_PULL_REQUEST" ] ; then
# Add website preview as PR Status - https://developer.github.com/v3/repos/statuses/#create-a-status

status_url="https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/statuses/$CIRCLE_SHA1"
params=$(jq --monochrome-output --null-input \
--arg target_url $preview_url \
'{ "state": "success", "target_url": $target_url, description: "Website added to IPFS", "context": "IPFS" }' )

echo "Github status update: $params"
curl --silent -X POST -H "Authorization: token $GITHUB_TOKEN" -H 'Content-Type: application/json' --data "$params" $status_url

elif [ "$CIRCLE_BRANCH" == "master" ] ; then
# Update DNSLink for domain

dnslink-dnsimple -d $DOMAIN -r _dnslink -l /ipfs/$hash

else
echo "Not a Pull Request or Master branch. Skipping."
fi

workflows:
version: 2
build-deploy:
jobs:
- build
- deploy:
context: ipfs-dns-deploy
requires:
- build