diff --git a/.github/workflows/add-labels-for-pr.yml b/.github/workflows/add-labels-for-pr.yml new file mode 100644 index 000000000..feec56d6a --- /dev/null +++ b/.github/workflows/add-labels-for-pr.yml @@ -0,0 +1,17 @@ +on: pull_request + +name: MeterSphere 通用 PR 处理 + +permissions: + pull-requests: write + +jobs: + generic_handler: + name: 为 PR 添加标签 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUBTOKEN }} + labels: ${{ github.base_ref }} diff --git a/.github/workflows/build-push-oss.yml b/.github/workflows/build-push-oss.yml new file mode 100644 index 000000000..fd14e0ae5 --- /dev/null +++ b/.github/workflows/build-push-oss.yml @@ -0,0 +1,88 @@ +name: Build Docker Image and Push without X-Pack Submodules + +on: + push: + branches: + - dev + - v1* + - test-build + workflow_dispatch: + +jobs: + build_push: + runs-on: ubuntu-latest + name: Build Docker Image and Push without X-Pack Submodules + steps: + - uses: actions/checkout@v2 + with: + submodules: false + token: ${{ secrets.ACCESS_TOKEN }} + + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v3.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: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Unzip jar + run: mkdir -p backend/target/dependency && (cd backend/target/dependency; jar -xf ../*.jar) + + - name: Prepare + id: prepare + run: | + DOCKER_IMAGE=metersphere/metersphere + DOCKER_PLATFORMS=linux/amd64,linux/arm64 + TAG_NAME=${{ env.GITHUB_REF_SLUG }}-oss + DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest-oss" + echo ::set-output name=docker_image::${DOCKER_IMAGE} + echo ::set-output name=version::${TAG_NAME} + echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ + --build-arg VERSION=${TAG_NAME} \ + --build-arg MS_VERSION=${{ env.GITHUB_REF_SLUG }}-${{ env.GITHUB_SHA_SHORT }} \ + --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ + --build-arg VCS_REF=${GITHUB_SHA::8} \ + ${DOCKER_IMAGE_TAGS} . + + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 + + - name: Docker Buildx (build) + run: | + docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} + + - name: Login to Registry + uses: docker/login-action@v1 + with: + username: metersphere + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Docker Buildx (push) + run: | + docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} + diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml new file mode 100644 index 000000000..0abea080a --- /dev/null +++ b/.github/workflows/build-push.yml @@ -0,0 +1,89 @@ +name: Build Docker Image and Push + +on: + push: + branches: + - master + - dev + - v1* + - test-build + workflow_dispatch: + +jobs: + build_push: + runs-on: ubuntu-latest + name: Build Docker Image and Push + steps: + - uses: actions/checkout@v2 + with: + submodules: true + token: ${{ secrets.ACCESS_TOKEN }} + + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v3.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: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Unzip jar + run: mkdir -p backend/target/dependency && (cd backend/target/dependency; jar -xf ../*.jar) + + - name: Prepare + id: prepare + run: | + DOCKER_IMAGE=metersphere/metersphere + DOCKER_PLATFORMS=linux/amd64,linux/arm64 + TAG_NAME=${{ env.GITHUB_REF_SLUG }} + DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest" + echo ::set-output name=docker_image::${DOCKER_IMAGE} + echo ::set-output name=version::${TAG_NAME} + echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ + --build-arg VERSION=${TAG_NAME} \ + --build-arg MS_VERSION=${{ env.GITHUB_REF_SLUG }}-${{ env.GITHUB_SHA_SHORT }} \ + --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ + --build-arg VCS_REF=${GITHUB_SHA::8} \ + ${DOCKER_IMAGE_TAGS} . + + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 + + - name: Docker Buildx (build) + run: | + docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} + + - name: Login to Registry + uses: docker/login-action@v1 + with: + username: metersphere + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Docker Buildx (push) + run: | + docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} + diff --git a/.github/workflows/create-pr-from-push.yml b/.github/workflows/create-pr-from-push.yml new file mode 100644 index 000000000..7c0e8a5a0 --- /dev/null +++ b/.github/workflows/create-pr-from-push.yml @@ -0,0 +1,17 @@ +on: + push: + branches: + - 'pr@**' + - 'repr@**' + +name: 针对特定分支名自动创建 PR + +jobs: + generic_handler: + name: 自动创建 PR + runs-on: ubuntu-latest + steps: + - name: Create pull request + uses: jumpserver/action-generic-handler@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }} diff --git a/.github/workflows/issue-close-require.yml b/.github/workflows/issue-close-require.yml new file mode 100644 index 000000000..2afeaeaa6 --- /dev/null +++ b/.github/workflows/issue-close-require.yml @@ -0,0 +1,18 @@ +name: Issue Close Require + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + issue-close-require: + runs-on: ubuntu-latest + steps: + - name: needs more info + uses: actions-cool/issues-helper@v2 + with: + actions: 'close-issues' + labels: '状态:待反馈' + inactive-day: 30 + body: | + 您超过30天未反馈信息,我们将关闭此Issue,如有需要您可以重新打开或提交新的Issue diff --git a/.github/workflows/issue-close.yml b/.github/workflows/issue-close.yml new file mode 100644 index 000000000..bb49b5877 --- /dev/null +++ b/.github/workflows/issue-close.yml @@ -0,0 +1,16 @@ +name: Issue Close Check + +on: + issues: + types: [closed] + +jobs: + issue-close-remove-labels: + runs-on: ubuntu-latest + steps: + - name: Remove labels + uses: actions-cool/issues-helper@v2 + if: ${{ !github.event.issue.pull_request }} + with: + actions: 'remove-labels' + labels: '状态:待处理' \ No newline at end of file diff --git a/.github/workflows/issue-comment.yml b/.github/workflows/issue-comment.yml new file mode 100644 index 000000000..e9e3fbc79 --- /dev/null +++ b/.github/workflows/issue-comment.yml @@ -0,0 +1,38 @@ +on: + issue_comment: + types: [created] + +name: Add issues workflow labels + +jobs: + add-label-if-is-author: + runs-on: ubuntu-latest + if: ${{ (github.event.issue.user.id == github.event.comment.user.id) && (!github.event.issue.pull_request) }} + steps: + - name: Add require handle label + uses: actions-cool/issues-helper@v2 + with: + actions: 'add-labels' + labels: '状态:待处理' + + - name: Remove require reply label + uses: actions-cool/issues-helper@v2 + with: + actions: 'remove-labels' + labels: '状态:待用户反馈' + + add-label-if-not-author: + runs-on: ubuntu-latest + if: ${{ (github.event.issue.user.id != github.event.comment.user.id) && (!github.event.issue.pull_request) && (github.event.issue.state == 'open') }} + steps: + - name: Add require replay label + uses: actions-cool/issues-helper@v2 + with: + actions: 'add-labels' + labels: '状态:待用户反馈' + + - name: Remove require handle label + uses: actions-cool/issues-helper@v2 + with: + actions: 'remove-labels' + labels: '状态:待处理' diff --git a/.github/workflows/issue-open.yml b/.github/workflows/issue-open.yml new file mode 100644 index 000000000..232d5da29 --- /dev/null +++ b/.github/workflows/issue-open.yml @@ -0,0 +1,16 @@ +name: Issue Open Check + +on: + issues: + types: [opened] + +jobs: + issue-open-add-labels: + runs-on: ubuntu-latest + steps: + - name: Add labels + uses: actions-cool/issues-helper@v2 + if: ${{ !github.event.issue.pull_request }} + with: + actions: 'add-labels' + labels: '状态:待处理' \ No newline at end of file diff --git a/.github/workflows/issue-recent-alert.yml b/.github/workflows/issue-recent-alert.yml new file mode 100644 index 000000000..0255783f5 --- /dev/null +++ b/.github/workflows/issue-recent-alert.yml @@ -0,0 +1,17 @@ +on: + schedule: + - cron: "0 1 * * *" + +name: Check recent handle issues + +jobs: + check-recent-issues-not-handle: + runs-on: ubuntu-latest + steps: + - name: Check recent issues and send msg + uses: jumpserver/action-issues-alert@master + with: + hook: ${{ secrets.WECHAT_GROUP_WEB_HOOK }} + type: recent + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/issue-untimely-alert.yml b/.github/workflows/issue-untimely-alert.yml new file mode 100644 index 000000000..2d3d7d5e1 --- /dev/null +++ b/.github/workflows/issue-untimely-alert.yml @@ -0,0 +1,17 @@ +on: + schedule: + - cron: "0 9 * * 1-5" + +name: Check untimely handle issues + +jobs: + check-untimely-handle-issues: + runs-on: ubuntu-latest + steps: + - name: Check untimely issues and send msg + uses: jumpserver/action-issues-alert@master + with: + hook: ${{ secrets.WECHAT_GROUP_WEB_HOOK }} + type: untimely + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file