Просмотр исходного кода

Merge pull request #1437 from weseek/support/github-actions

Support/GitHub actions
Yuki Takei 6 лет назад
Родитель
Сommit
d36b523d1f

+ 48 - 0
.github/workflows/build-default.yml

@@ -0,0 +1,48 @@
+name: Release Docker Images (Default)
+
+on:
+  push:
+    tags:
+      - v3.*
+    branches:
+      - rc/*
+
+jobs:
+
+  build-rc:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v1
+
+    - name: Set up Docker Buildx
+      uses: crazy-max/ghaction-docker-buildx@v1.0.4
+
+    - name: Login to docker.io registry
+      run: |
+        echo ${{ secrets. DOCKER_REGISTRY_PASSWORD }} | docker login --username wsmoogle --password-stdin
+
+    - name: Build Docker Image
+      run: |
+        CACHE_REF=weseek/growi-cache:3
+        docker buildx build \
+          --tag growi \
+          --platform linux/amd64 \
+          --load \
+          --cache-from=type=registry,ref=$CACHE_REF \
+          --cache-to=type=registry,ref=$CACHE_REF,mode=max \
+          --file ./docker/Dockerfile .
+
+    - name: Get SemVer
+      run: |
+        semver=`npm run version --silent`
+        echo ::set-env name=SEMVER::$(echo $semver)
+
+    - name: Docker Tags by SemVer
+      uses: weseek/ghaction-docker-tags-by-semver@v1.0.3
+      with:
+        source: growi
+        target: weseek/growi
+        semver: ${{ env.SEMVER }}
+        publish: true

+ 63 - 0
.github/workflows/build-nocdn.yml

@@ -0,0 +1,63 @@
+name: Release Docker Images (NOCDN)
+
+on:
+  push:
+    tags:
+      - v3.*
+
+jobs:
+
+  build-rc:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v1
+
+    - name: Set up Docker Buildx
+      uses: crazy-max/ghaction-docker-buildx@v1.0.4
+
+    - name: Login to docker.io registry
+      run: |
+        echo ${{ secrets. DOCKER_REGISTRY_PASSWORD }} | docker login --username wsmoogle --password-stdin
+
+    - name: Build Docker Image
+      run: |
+        CACHE_REF=weseek/growi-cache:3-nocdn
+        docker buildx build \
+          --tag growi \
+          --build-arg flavor=nocdn \
+          --platform linux/amd64 \
+          --load \
+          --cache-from=type=registry,ref=$CACHE_REF \
+          --file ./docker/Dockerfile .
+
+    - name: Get SemVer
+      run: |
+        semver=`npm run version --silent`
+        echo ::set-env name=SEMVER::$(echo $semver)
+
+    - name: Docker Tags by SemVer
+      uses: weseek/ghaction-docker-tags-by-semver@v1.0.3
+      with:
+        source: growi
+        target: weseek/growi
+        semver: ${{ env.SEMVER }}
+        suffix: -nocdn
+        publish: true
+
+  publish-desc:
+
+    runs-on: ubuntu-latest
+    needs: build
+
+    steps:
+    - uses: actions/checkout@v1
+
+    - name: Update Docker Hub Description
+      uses: peter-evans/dockerhub-description@v2.1.0
+      env:
+        DOCKERHUB_USERNAME: wsmoogle
+        DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
+        DOCKERHUB_REPOSITORY: weseek/growi
+        README_FILEPATH: ./docker/README.md

+ 164 - 0
.github/workflows/ci.yml

@@ -0,0 +1,164 @@
+name: Node CI
+
+on: [push]
+
+jobs:
+
+  resolve-dependencies:
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        node-version: [10.x, 12.x]
+
+    steps:
+    - uses: actions/checkout@v1
+    - name: Use Node.js ${{ matrix.node-version }}
+      uses: actions/setup-node@v1
+      with:
+        node-version: ${{ matrix.node-version }}
+    - name: Cache/Restore node_modules
+      id: cache
+      uses: actions/cache@v1
+      with:
+        path: node_modules
+        key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+    - name: Install dependencies
+      if: steps.cache.outputs.cache-hit != 'true'
+      run: |
+        yarn
+    - name: Install plugins
+      if: steps.cache.outputs.cache-hit != 'true'
+      run: |
+        yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
+        yarn add -D react-images react-motion
+    - name: Print dependencies
+      run: |
+        echo -n "node " && node -v
+        echo -n "npm " && npm -v
+        yarn list --depth=0
+
+
+  test:
+    runs-on: ubuntu-latest
+    needs: resolve-dependencies
+
+    strategy:
+      matrix:
+        node-version: [10.x, 12.x]
+
+    steps:
+    - uses: actions/checkout@v1
+    - name: Use Node.js ${{ matrix.node-version }}
+      uses: actions/setup-node@v1
+      with:
+        node-version: ${{ matrix.node-version }}
+    - name: Cache/Restore node_modules
+      uses: actions/cache@v1
+      with:
+        path: node_modules
+        key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+    - name: yarn lint
+      run: |
+        yarn lint
+    - name: Launch MongoDB
+      uses: wbari/start-mongoDB@v0.2
+      with:
+        mongoDBVersion: 3.6
+    - name: yarn test
+      run: |
+        yarn test
+      env:
+        MONGO_URI: mongodb://localhost:27017/growi_test
+
+    - name: Slack Notification
+      uses: homoluctus/slatify@master
+      if: failure()
+      with:
+        type: ${{ job.status }}
+        job_name: '*test (${{ matrix.node-version }})*'
+        channel: '#ci'
+        url: ${{ secrets.SLACK_WEBHOOK_URL }}
+
+  build-dev:
+    runs-on: ubuntu-latest
+    needs: resolve-dependencies
+
+    strategy:
+      matrix:
+        node-version: [10.x, 12.x]
+
+    steps:
+    - uses: actions/checkout@v1
+    - name: Use Node.js ${{ matrix.node-version }}
+      uses: actions/setup-node@v1
+      with:
+        node-version: ${{ matrix.node-version }}
+    - name: Cache/Restore node_modules
+      uses: actions/cache@v1
+      with:
+        path: node_modules
+        key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+    - name: yarn build:dev
+      run: |
+        yarn build:dev
+
+    - name: Slack Notification
+      uses: homoluctus/slatify@master
+      if: failure()
+      with:
+        type: ${{ job.status }}
+        job_name: '*build-dev (${{ matrix.node-version }})*'
+        channel: '#ci'
+        url: ${{ secrets.SLACK_WEBHOOK_URL }}
+
+
+  build-prod:
+    runs-on: ubuntu-latest
+    needs: resolve-dependencies
+
+    strategy:
+      matrix:
+        node-version: [10.x, 12.x]
+
+    steps:
+    - uses: actions/checkout@v1
+    - name: Use Node.js ${{ matrix.node-version }}
+      uses: actions/setup-node@v1
+      with:
+        node-version: ${{ matrix.node-version }}
+    - name: Cache/Restore node_modules
+      uses: actions/cache@v1
+      with:
+        path: node_modules
+        key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+    - name: Launch MongoDB
+      uses: wbari/start-mongoDB@v0.2
+      with:
+        mongoDBVersion: 3.6
+    - name: yarn build:prod:analyze
+      run: |
+        yarn build:prod:analyze
+    - name: Shrink dependencies for production
+      run: |
+        yarn install --production
+    - name: yarn server:prod:ci
+      run: |
+        yarn server:prod:ci
+      env:
+        MONGO_URI: mongodb://localhost:27017/growi
+
+    - name: Upload reports
+      uses: actions/upload-artifact@v1
+      if: success()
+      with:
+        name: report
+        path: report
+    - name: Slack Notification
+      uses: homoluctus/slatify@master
+      if: failure()
+      with:
+        type: ${{ job.status }}
+        job_name: '*build-prod (${{ matrix.node-version }})*'
+        channel: '#ci'
+        url: ${{ secrets.SLACK_WEBHOOK_URL }}

+ 0 - 30
.github/workflows/main.yml

@@ -1,30 +0,0 @@
-name: CI
-
-on:
-  push:
-    branches:
-      - support/github-actions
-
-jobs:
-  build:
-
-    runs-on: ubuntu-latest
-
-    steps:
-    - uses: actions/checkout@v1
-
-    - name: Bump version
-      run: sh ./bin/github-actions/bump-version.sh
-
-    - name: Set up Docker Buildx
-      uses: crazy-max/ghaction-docker-buildx@v1.0.4
-      with:
-        # Buildx version. Example: v0.3.0
-        version: # optional, default is latest
-
-    - name: Build Docker Image
-      run: |
-        docker buildx build \
-          --platform linux/amd64 \
-          --output "type=image,push=false" \
-          --file ./docker/Dockerfile .

+ 37 - 0
.github/workflows/release.yml

@@ -0,0 +1,37 @@
+name: GitHub Release
+
+on:
+  push:
+    branches:
+      - release
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v1
+      with:
+        fetch-depth: 1
+
+    - name: Init Git
+      run: |
+        git config --local user.name "GitHub Action"
+        git config --local user.email "info@weseek.co.jp"
+
+    - name: Bump version
+      run: |
+        npm version patch
+        sh ./bin/github-actions/bump-version.sh
+
+    - name: Commit
+      run: |
+        git commit -am "Release $RELEASE_VERSION"
+
+    - name: Push tag
+      uses: ad-m/github-push-action@master
+      with:
+        branch: null
+        github_token: ${{ secrets. GITHUB_TOKEN }}
+

+ 0 - 95
.github/workflows/test.yml

@@ -1,95 +0,0 @@
-name: Node CI
-
-# on: [push]
-on:
-  push:
-    branches:
-      - support/github-actions
-
-jobs:
-
-  resolve-dependencies:
-    runs-on: ubuntu-latest
-
-    strategy:
-      matrix:
-        node-version: [10.x, 12.x]
-
-    steps:
-    - uses: actions/checkout@v1
-    - name: Use Node.js ${{ matrix.node-version }}
-      uses: actions/setup-node@v1
-      with:
-        node-version: ${{ matrix.node-version }}
-    - name: install dependencies
-      run: |
-        yarn
-    - name: install plugins
-      run: |
-        yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
-        yarn add -D react-images react-motion
-    - name: print dependencies
-      run: |
-        echo -n "node " && node -v
-        echo -n "npm " && npm -v
-        yarn list --depth=0
-
-
-  lint:
-    runs-on: ubuntu-latest
-    needs: resolve-dependencies
-
-    steps:
-    - uses: actions/checkout@v1
-    - name: yarn lint
-      run: |
-        yarn lint
-
-
-  test:
-    runs-on: ubuntu-latest
-    needs: resolve-dependencies
-
-    steps:
-    - name: Launch MongoDB
-      uses: wbari/start-mongoDB@v0.2
-      with:
-        mongoDBVersion: 3.6
-
-    - name: yarn test
-      run: |
-        yarn test
-      env:
-        MONGO_URI: mongodb://localhost:27017/growi_test
-
-
-  build-dev:
-    runs-on: ubuntu-latest
-    needs: resolve-dependencies
-
-    steps:
-    - name: yarn build:dev
-      run: |
-        yarn build:dev
-
-
-  build-prod:
-    runs-on: ubuntu-latest
-    needs: resolve-dependencies
-
-    steps:
-    - name: Launch MongoDB
-      uses: wbari/start-mongoDB@v0.2
-      with:
-        mongoDBVersion: 3.6
-    - name: yarn build:prod:analyze
-      run: |
-        yarn build:prod:analyze
-    - name: shrink dependencies for production
-      run: |
-        yarn install --production
-    - name: yarn server:prod:ci
-      run: |
-        yarn server:prod:ci
-      env:
-        MONGO_URI: mongodb://localhost:27017/growi

+ 3 - 172
wercker.yml

@@ -1,187 +1,18 @@
 box: node:12-slim
 
-services:
-  - mongo:3.6
-
-
 test:
   steps:
     - script:
-      name: set yarn cache-folder
-      code: yarn config set cache-folder $WERCKER_CACHE_DIR/yarn
-
-    - script:
-      name: install dependencies
-      code: |
-        yarn
-
-    - script:
-      name: install plugins
-      code: |
-        yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
-        yarn add -D react-images react-motion
-
-    - script:
-      name: print dependencies
-      code: |
-        echo -n "node " && node -v
-        echo -n "npm " && npm -v
-        yarn list --depth=0
-
-    - script:
-      name: yarn lint
-      code: |
-        yarn lint
-
-    - script:
-      name: yarn test
-      code: |
-        export MONGO_URI=mongodb://$MONGO_PORT_27017_TCP_ADDR/growi_test
-        echo "export MONGO_URI=$MONGO_URI"
-        yarn test
-
-  after-steps:
-    - slack-notifier:
-      url: $SLACK_WEBHOOK_URL
-      channel: ci
-      username: wercker
-      notify_on: "failed"
+      code: echo "CI processes are migrated to GitHub Actions"
 
 
 build-prod:
   steps:
     - script:
-      name: set yarn cache-folder
-      code: yarn config set cache-folder $WERCKER_CACHE_DIR/yarn
-
-    - script:
-      name: yarn build:prod:analyze
-      code: |
-        yarn build:prod:analyze
-
-    - script:
-      name: shrink dependencies for production
-      code: |
-        yarn install --production
-
-    - script:
-      name: yarn server:prod:ci
-      code: |
-        export MONGO_URI=mongodb://$MONGO_PORT_27017_TCP_ADDR/growi
-        echo "export MONGO_URI=$MONGO_URI"
-        yarn server:prod:ci
-
-  after-steps:
-    - script:
-      name: copy report to artifacts
-      code: |
-        cp -r report $WERCKER_REPORT_ARTIFACTS_DIR
-
-    - slack-notifier:
-      url: $SLACK_WEBHOOK_URL
-      channel: ci
-      username: wercker
-      notify_on: "failed"
+      code: echo "CI processes are migrated to GitHub Actions"
 
 
 build-dev:
   steps:
     - script:
-      name: set yarn cache-folder
-      code: yarn config set cache-folder $WERCKER_CACHE_DIR/yarn
-
-    - script:
-      name: yarn build:dev
-      code: |
-        yarn build:dev
-
-  after-steps:
-    - slack-notifier:
-      url: $SLACK_WEBHOOK_URL
-      channel: ci
-      username: wercker
-      notify_on: "failed"
-
-
-release: # would be run on release branch
-  steps:
-    - install-packages:
-      packages: jq
-
-    - script:
-      name: bump version
-      code: |
-        sh ./bin/wercker/init-git.sh
-        # git reset
-        git reset --hard
-        # npm version to bump version
-        npm version patch
-
-    - script:
-      name: get RELEASE_VERSION
-      code: |
-        export RELEASE_VERSION=`npm run version --silent`
-        echo "export RELEASE_VERSION=$RELEASE_VERSION"
-
-    - script:
-      name: commit and push
-      code: |
-        TMP_RELEASE_BRANCH=tmp/release-$RELEASE_VERSION
-        git checkout -B $TMP_RELEASE_BRANCH
-        git push -u origin HEAD:$TMP_RELEASE_BRANCH
-        export RELEASE_GIT_COMMIT=`git rev-parse HEAD`
-
-    - github-create-release:
-      token: $GITHUB_TOKEN
-      tag: v$RELEASE_VERSION
-      target-commitish: $RELEASE_GIT_COMMIT
-
-    - script:
-      name: remove temporary release branch
-      code: |
-        git push --delete origin $TMP_RELEASE_BRANCH
-
-    - script:
-      name: trigger growi-docker release pipeline
-      code: GROWI_DOCKER_PIPELINE_ID=$GROWI_DOCKER_PIPELINE_ID_CDN sh ./bin/wercker/trigger-growi-docker.sh
-
-    - script:
-      name: trigger growi-docker release-nocdn pipeline
-      code: GROWI_DOCKER_PIPELINE_ID=$GROWI_DOCKER_PIPELINE_ID_NOCDN sh ./bin/wercker/trigger-growi-docker.sh
-
-    - script:
-      name: trigger growi-docs deploy pipeline
-      code: sh ./bin/wercker/trigger-growi-docs.sh
-
-  after-steps:
-    - slack-notifier:
-      url: $SLACK_WEBHOOK_URL
-      channel: ci
-      username: wercker
-      notify_on: "failed"
-
-
-release-rc: # would be run on rc/* branches
-  steps:
-    - install-packages:
-      packages: jq
-
-    - script:
-      name: get RELEASE_VERSION
-      code: |
-        export RELEASE_VERSION=`npm run version --silent`
-        export RELEASE_GIT_COMMIT=$WERCKER_GIT_COMMIT
-        echo "export RELEASE_VERSION=$RELEASE_VERSION"
-        echo "export RELEASE_GIT_COMMIT=$RELEASE_GIT_COMMIT"
-
-    - script:
-      name: trigger growi-docker release-rc pipeline
-      code: sh ./bin/wercker/trigger-growi-docker.sh
-
-  after-steps:
-    - slack-notifier:
-      url: $SLACK_WEBHOOK_URL
-      channel: ci
-      username: wercker
-      notify_on: "failed"
-
+      code: echo "CI processes are migrated to GitHub Actions"