From 9f9a6c39656e7adb50970e5b49d4c7de736231bd Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Tue, 19 May 2020 18:15:21 +0200 Subject: [PATCH] CI Add deployment setup for pyodide-cdn2.iodide.io (#666) --- .circleci/config.yml | 32 +++++++++++++++++++++----------- .circleci/s3-website-config.json | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 .circleci/s3-website-config.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f7ad8e79..653b9be47 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -143,6 +143,11 @@ jobs: - checkout - attach_workspace: at: . + - run: + name: Install requirements + command: | + apk add --no-cache --update python3 + python3 -m pip install awscli - run: name: Deploy Github Releases command: | @@ -151,23 +156,30 @@ jobs: popd ghr -t "${GITHUB_TOKEN}" -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" -c "${CIRCLE_SHA1}" -delete "${CIRCLE_TAG}" ./pyodide-build-${CIRCLE_TAG}.tar.bz2 - deploy-netlify: + - run: + name: Deploy to pyodide-cdn2.iodide.io + command: | + aws s3 sync --delete build/ "s3://pyodide-cdn2.iodide.io/v${CIRCLE_TAG}/full/" --cache-control max-age=30758400 # 1 year + # update 301 redirect for the /latest/* route. + aws s3api put-bucket-website --cli-input-json file://.circleci/s3-website-config.json + + deploy-s3: docker: - - image: circleci/node:latest + - image: circleci/python:3.7.7 steps: - checkout - attach_workspace: at: . - run: - name: Install netlify-cli + name: Install requirements command: | - sudo npm install netlify-cli -g + sudo apt-get install -y groff + python3 -m pip install awscli - run: - name: Deploy to netlify + name: Deploy to pyodide-cdn2.iodide.io command: | - cp src/_headers build - netlify deploy --prod --dir=build -m "Deployed from CircleCI" + aws s3 sync --delete build/ "s3://pyodide-cdn2.iodide.io/dev/full/" --cache-control max-age=3600 # 1 hour workflows: version: 2 @@ -203,12 +215,10 @@ workflows: ignore: /.*/ tags: only: /^\d+\.\d+\.\d+$/ - - deploy-netlify: + - deploy-s3: requires: - test-firefox - test-python filters: branches: - ignore: /.*/ - tags: - only: /^\d+\.\d+\.\d+$/ + only: master diff --git a/.circleci/s3-website-config.json b/.circleci/s3-website-config.json new file mode 100644 index 000000000..21e3d4f5f --- /dev/null +++ b/.circleci/s3-website-config.json @@ -0,0 +1,18 @@ +{ + "Bucket": "pyodide-cdn2.iodide.io", + "WebsiteConfiguration": { + "IndexDocument": { + "Suffix": "index.html" + }, + "RoutingRules": [ + { + "Condition": { + "KeyPrefixEquals": "latest/" + }, + "Redirect": { + "ReplaceKeyPrefixWith": "v0.14.3/" + } + } + ] + } +}