From 0d8b82e386c47e0ed5b4e0eb95f8766972b9a352 Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Fri, 30 Oct 2020 19:38:38 +0300 Subject: [PATCH] Migrated to Github Actions --- .drone.yml | 41 ----------------------------------- .github/workflows/build.yml | 35 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 38 ++++++++++++++++++++++++++++++++ deploy.sh | 11 +++++----- 4 files changed, 78 insertions(+), 47 deletions(-) delete mode 100644 .drone.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 4c132d2..0000000 --- a/.drone.yml +++ /dev/null @@ -1,41 +0,0 @@ -clone: - git: - image: plugins/git - tags: true - -pipeline: - - build: - image: node:12-alpine - commands: - - npm install - - npm run build - when: - event: [push, tag, pull_request] - - selenoid_website_latest_image: - image: plugins/docker - registry: registry.aerokube.com - repo: registry.aerokube.com/selenoid/website - secrets: [ docker_username, docker_password ] - tags: [ 'latest' ] - when: - branch: master - event: push - - selenoid_website_release_image: - image: plugins/docker - registry: registry.aerokube.com - repo: registry.aerokube.com/selenoid/website - secrets: [ docker_username, docker_password ] - tags: [ '${DRONE_TAG}', 'latest-release' ] - when: - event: tag - - selenoid_website_push: - image: golang:1.12.5 - commands: - - ./deploy.sh - secrets: [ github_token ] - when: - event: [tag] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..23e8d11 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,35 @@ +name: build + +on: + pull_request: + push: + branches: + - master + +jobs: + website: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v1 + with: + node-version: 12.x + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install Dependencies + run: npm install + + - name: Build + run: npm run build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2eb258a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: release + +on: + release: + types: [published] + +jobs: + website: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v1 + with: + node-version: 12.x + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install Dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Deploy + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + run: ./deploy.sh diff --git a/deploy.sh b/deploy.sh index 0b911b2..bfaa8c2 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,15 +1,14 @@ #!/bin/bash WD=$(pwd) -CLONE_DIR="/go/website" -git clone https://${GITHUB_TOKEN}@github.com/aerokube/selenoid.git ${CLONE_DIR} +CLONE_DIR="${GITHUB_WORKSPACE}/selenoid" +git clone -b gh-pages https://${GITHUB_TOKEN}@github.com/aerokube/selenoid.git ${CLONE_DIR} cd ${CLONE_DIR} -git config user.name ${DRONE_COMMIT_AUTHOR} -git config user.email ${DRONE_COMMIT_AUTHOR_EMAIL} -git checkout gh-pages +git config user.name "${GITHUB_REPOSITORY}" +git config user.email "aerokube@aerokube.github.com" git rm ${CLONE_DIR}/main.*.css git rm ${CLONE_DIR}/main.*.js cp -R ${WD}/dist/* ${CLONE_DIR} git add --all -git commit -am "Updated by ${DRONE_COMMIT_AUTHOR}" +git commit -am "Updated website" git push origin HEAD:gh-pages