diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..0af8b76a0 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,68 @@ +version: 2 +jobs: + build: + docker: + - image: circleci/node:10.15.1 + steps: + - checkout + - run: + command: npm ci + - run: + command: npm run build + - persist_to_workspace: + root: . + paths: + - build + + deploy: + docker: + - image: olizilla/ipfs-dns-deploy + environment: + DOMAIN: webui.ipfs.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 diff --git a/.env b/.env new file mode 100644 index 000000000..0454adfc4 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +REACT_APP_VERSION=$npm_package_version diff --git a/.travis.yml b/.travis.yml index a47bbdb61..b2856bb82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - 8.12.0 + - 10.15.1 env: - NO_SANDBOX=true install: npm ci diff --git a/Makefile b/Makefile deleted file mode 100644 index b28e9749a..000000000 --- a/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -build: - npm --version - # Pin the npm version to 6.4.1 (as bundled with node 8.12) - # Using npx is a workaround for npm<5.6 not being able to self update - # See: https://github.com/ipfs/ci-websites/issues/3 - npx npm@5.6 i -g npm@6.4.1 - npm --version - npm ci - npm run lint - CI=true npm test - npm run build diff --git a/README.md b/README.md index 3d2346c16..f8fd85fc3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The IPFS WebUI is a **work-in-progress**. Help us make it better! We use the issues on this repo to track the work and it's part of the wider [IPFS GUI project](https://github.com/ipfs/ipfs-gui). -The app uses the IPFS HTTP CLIENT to get data from the ipfs node. It will use the `window.ipfs` api provided by the [IPFS Companion](https://github.com/ipfs-shipyard/ipfs-companion) web-extension where available, and fallback to using [js-ipfs-http-client](https://github.com/ipfs/js-ipfs-http-client) where not. +The app uses [`ipfs-http-client`](https://github.com/ipfs/js-ipfs-http-client) to communicate with your local IPFS node. The app is built with [`create-react-app`](https://github.com/facebook/create-react-app). Please read the [docs](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#table-of-contents). diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile deleted file mode 100644 index 0ddc73d41..000000000 --- a/ci/Jenkinsfile +++ /dev/null @@ -1,7 +0,0 @@ -website([ - website: 'webui.ipfs.io', - build_directory: 'build/', - record: [ - 'master': '_dnslink', - ] -]) diff --git a/src/index.js b/src/index.js index 477491f6f..e27e0e6bf 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,11 @@ import bundleCache from './lib/bundle-cache' import { I18nextProvider } from 'react-i18next' import i18n from './i18n' +const appVersion = process.env.REACT_APP_VERSION +const gitRevision = process.env.REACT_APP_GIT_REV + +console.log(`IPFS Web UI - v${appVersion} - https://github.com/ipfs-shipyard/ipfs-webui/commit/${gitRevision}`) + async function render () { const initialData = await bundleCache.getAll() if (initialData && process.env.NODE_ENV !== 'production') {