You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ti...@apache.org on 2022/12/17 06:53:09 UTC

[pulsar-site] branch main updated: Reuse workflows (#338)

This is an automated email from the ASF dual-hosted git repository.

tison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git


The following commit(s) were added to refs/heads/main by this push:
     new 7379b6cead8 Reuse workflows (#338)
7379b6cead8 is described below

commit 7379b6cead89985f630f7124ba6a0bfc0877a43a
Author: tison <wa...@gmail.com>
AuthorDate: Sat Dec 17 14:53:04 2022 +0800

    Reuse workflows (#338)
    
    Signed-off-by: tison <wa...@gmail.com>
---
 .github/actions/sync-content/action.yml | 65 +++++++++++++++++++++++++++++++++
 .github/workflows/ci-precommit.yml      | 16 +++++++-
 .github/workflows/ci-sync-content.yml   | 51 ++------------------------
 3 files changed, 82 insertions(+), 50 deletions(-)

diff --git a/.github/actions/sync-content/action.yml b/.github/actions/sync-content/action.yml
new file mode 100644
index 00000000000..bdfb931eca2
--- /dev/null
+++ b/.github/actions/sync-content/action.yml
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Synchronize Website Content
+description: Synchronize website content from the main repo
+runs:
+  using: composite
+  steps:
+    - name: Install poetry
+      run: pipx install poetry
+      shell: bash
+    - uses: actions/setup-python@v4
+      with:
+        python-version: '3.10'
+        cache: 'poetry'
+
+    - uses: actions/checkout@v3
+      with:
+        repository: apache/pulsar
+        path: tmp/pulsar
+    - name: Cache local Maven repository
+      uses: actions/cache@v3
+      with:
+        path: |
+          ~/.m2/repository/*/*/*
+          !~/.m2/repository/org/apache/pulsar
+        key: ${{ runner.os }}-m2-dependencies-website-${{ hashFiles('**/pom.xml') }}
+        restore-keys: |
+          ${{ runner.os }}-m2-dependencies-all-${{ hashFiles('**/pom.xml') }}
+          ${{ runner.os }}-m2-dependencies-core-modules-${{ hashFiles('**/pom.xml') }}
+          ${{ runner.os }}-m2-dependencies-core-modules-
+    - name: Set up JDK 17
+      uses: actions/setup-java@v3
+      with:
+        distribution: 'temurin'
+        java-version: 17
+    - name: Run install by skip tests
+      working-directory: tmp/pulsar
+      env:
+        MAVEN_OPTS: -Xss1500k -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
+      run: mvn -B -ntp install -Pcore-modules,swagger,-main -DskipTests -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true
+      shell: bash
+
+    - name: Update site sources
+      working-directory: tools/pytools
+      run: |
+        poetry install
+        poetry run bin/reference-doc-generator.py --master-path=$GITHUB_WORKSPACE/tmp/pulsar
+        poetry run bin/rest-apidoc-generator.py --master-path=$GITHUB_WORKSPACE/tmp/pulsar
+        poetry run bin/site-updater.py --master-path=$GITHUB_WORKSPACE/tmp/pulsar
+      shell: bash
diff --git a/.github/workflows/ci-precommit.yml b/.github/workflows/ci-precommit.yml
index c0f33c6fdbc..01014940af2 100644
--- a/.github/workflows/ci-precommit.yml
+++ b/.github/workflows/ci-precommit.yml
@@ -19,8 +19,6 @@ name: CI - Precommit
 on:
   pull_request:
     branches: [main]
-  push:
-    branches: [main]
 
 jobs:
   license:
@@ -32,3 +30,17 @@ jobs:
       - uses: apache/skywalking-eyes/header@main
         with:
           config: tools/ci/licenserc.yml
+
+  # TODO: If it causes too much time to every PR, split to another
+  # workflow file and filter by paths:
+  # - '.github/actions/sync-content/action.yml'
+  # - '.github/workflows/ci-precommit.yml'
+  # - 'tools/pytools/**'
+  sync-without-push:
+    name: Check synchronize content
+    runs-on: ubuntu-latest
+    timeout-minutes: 180
+    steps:
+      - uses: actions/checkout@v3
+      - name: Sync content without push
+        uses: ./.github/actions/sync-content
diff --git a/.github/workflows/ci-sync-content.yml b/.github/workflows/ci-sync-content.yml
index 8e3274a43f1..f5ff1b883b2 100644
--- a/.github/workflows/ci-sync-content.yml
+++ b/.github/workflows/ci-sync-content.yml
@@ -17,64 +17,19 @@
 
 name: CI - Synchronize Content
 on:
-  pull_request:
-    paths:
-      - '.github/workflows/ci-sync-content.yml'
-      - 'tools/pytools/**'
   schedule:
     - cron: "0 * * * *"
   workflow_dispatch:
 
 jobs:
-  build-website:
+  sync-content-and-push:
     if: ${{ github.repository == 'apache/pulsar-site' }}
     name: Synchronize Content from Main Repo
     runs-on: ubuntu-latest
     timeout-minutes: 180
     steps:
       - uses: actions/checkout@v3
-        if: ${{ github.event_name != 'pull_request' }}
         with:
           token: ${{ secrets.PULSARBOT_TOKEN }}
-          persist-credentials: true
-      - uses: actions/checkout@v3
-        if: ${{ github.event_name == 'pull_request' }}
-
-      - name: Install poetry
-        run: pipx install poetry
-      - uses: actions/setup-python@v4
-        with:
-          python-version: '3.10'
-          cache: 'poetry'
-
-      - uses: actions/checkout@v3
-        with:
-          repository: apache/pulsar
-          path: tmp/pulsar
-      - name: Cache local Maven repository
-        uses: actions/cache@v3
-        with:
-          path: |
-            ~/.m2/repository/*/*/*
-            !~/.m2/repository/org/apache/pulsar
-          key: ${{ runner.os }}-m2-dependencies-website-${{ hashFiles('**/pom.xml') }}
-          restore-keys: |
-            ${{ runner.os }}-m2-dependencies-all-${{ hashFiles('**/pom.xml') }}
-            ${{ runner.os }}-m2-dependencies-core-modules-${{ hashFiles('**/pom.xml') }}
-            ${{ runner.os }}-m2-dependencies-core-modules-
-      - name: Set up JDK 17
-        uses: actions/setup-java@v3
-        with:
-          distribution: 'temurin'
-          java-version: 17
-      - name: Run install by skip tests
-        working-directory: tmp/pulsar
-        run: mvn -B -ntp install -Pcore-modules,swagger,-main -DskipTests -DskipSourceReleaseAssembly=true -Dspotbugs.skip=true -Dlicense.skip=true
-
-      - name: Update site sources
-        working-directory: tools/pytools
-        run: |
-          poetry install
-          poetry run bin/reference-doc-generator.py --master-path=$GITHUB_WORKSPACE/tmp/pulsar
-          poetry run bin/rest-apidoc-generator.py --master-path=$GITHUB_WORKSPACE/tmp/pulsar
-          poetry run bin/site-updater.py --master-path=$GITHUB_WORKSPACE/tmp/pulsar
+      - name: Sync content and push
+        uses: ./.github/actions/sync-content