diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..d58eef14 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,26 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '16' + + - run: npm install + - run: npm run ghpages + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./ghpages diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..0bd3c638 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,24 @@ +name: Lint Frontend Code + +on: + push: + branches: [ master, develop ] + pull_request: + branches: [ master, develop ] + +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '16' + + - run: npm install + + - name: Lint + run: npm run lint diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3123acd4..00000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: -- stable -script: npm test -after_success: npm run deploy diff --git a/package.json b/package.json index 882b6481..fcaaaafc 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,9 @@ "bundle:main": "webpack --config ./scripts/webpack.prod.js", "bundle:plugin": "webpack --config scripts/webpack.prod.plugins.js", "bundle": "npm-run-all bundle:main bundle:plugin", - "preghpages": "rimraf ./.tmp", + "preghpages": "rimraf ./ghpages", "ghpages": "webpack --config ./scripts/webpack.ghpages.js", + "postghpages": "cpx 'demo/{images/*,index.html}' ghpages -v", "deploy": "./scripts/deploy.sh", "test": "npm run lint && tsc --noEmit", "release": "node ./scripts/release.js" diff --git a/scripts/deploy.sh b/scripts/deploy.sh deleted file mode 100755 index eb2534c5..00000000 --- a/scripts/deploy.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -set -e # Exit with nonzero exit code if anything fails - -SOURCE_BRANCH="master" -TARGET_BRANCH="gh-pages" - -# Pull requests and commits to other branches shouldn't try to deploy, just build to verify -if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then - echo "Skipping deploy; just doing a build." - exit 0 -fi - -# Save some useful information -REPO=`git config remote.origin.url` -COMMIT_AUTHOR_NAME=`git show -s --format='%an'` -COMMIT_AUTHOR_EMAIL=`git show -s --format='%ae'` -SSH_REPO=${REPO/\/\/github.com/\/\/$GITHUB_TOKEN@github.com} -SHA=`git rev-parse --verify HEAD` - -# Clone the existing gh-pages for this repo into out/ -# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply) -git clone $REPO out -cd out - -echo "Checking out ${TARGET_BRANCH} branch" -git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH - -# Clean out existing contents -echo "Removing old contents" -cd .. -rm -rf ./out/**/* || exit 0 - -# Compiling -npm run ghpages - -# Copy files -echo "Copying new contents" -cp -v ./__demo__/index.html ./out -cp -vr ./__demo__/images ./out -cp -vr ./.tmp/* ./out -cd ./out - -# Now let's go have some fun with the cloned repo -git config user.name "$COMMIT_AUTHOR_NAME" -git config user.email "$COMMIT_AUTHOR_EMAIL" - -# Commit the "changes", i.e. the new version. -# The delta will show diffs between new and old versions. -git add --all -git commit -m "Deploy to GitHub Pages: ${SHA}" - -# Now we can push. -git push --force $SSH_REPO $TARGET_BRANCH