From c6e9512a8b9f8ee61646f9286fd85f2c05ac31bf Mon Sep 17 00:00:00 2001 From: zsq1234 <2387311298@qq.com> Date: Mon, 5 Aug 2024 11:25:07 +0800 Subject: [PATCH] feat: add univer ci image build --- .github/actions/build-docker-image/action.yml | 16 +- .github/workflows/ci-univer.yml | 143 ++++++++++++++++++ 2 files changed, 156 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci-univer.yml diff --git a/.github/actions/build-docker-image/action.yml b/.github/actions/build-docker-image/action.yml index 378f6bdb01b9..f565a063ffb6 100644 --- a/.github/actions/build-docker-image/action.yml +++ b/.github/actions/build-docker-image/action.yml @@ -8,6 +8,12 @@ inputs: required: true release: required: true + registry: + required: false + default: ghcr.io + namespace: + required: false + default: "" username: required: false password: @@ -34,9 +40,13 @@ runs: run: | cd ${{ inputs.root-dir }} - LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]") + if [[ "${{ inputs.namespace }}" == "" ]]; then + NAMESPACE=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]") + else + NAMESPACE="${{ inputs.namespace }}" + fi; - IMAGE_NAME_BASE="ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${{ inputs.docker-tag }}" + IMAGE_NAME_BASE="${{ inputs.registry }}/${NAMESPACE}/rocket.chat:${{ inputs.docker-tag }}" IMAGE_NAME="${IMAGE_NAME_BASE}.${{ inputs.release }}" @@ -68,7 +78,7 @@ runs: if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop' uses: docker/login-action@v2 with: - registry: ghcr.io + registry: ${{ inputs.registry }} username: ${{ inputs.username }} password: ${{ inputs.password }} diff --git a/.github/workflows/ci-univer.yml b/.github/workflows/ci-univer.yml new file mode 100644 index 000000000000..71a413735d18 --- /dev/null +++ b/.github/workflows/ci-univer.yml @@ -0,0 +1,143 @@ +name: CI Univer + +on: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + release-versions: + name: ⚙️ Variables Setup + runs-on: ubuntu-latest + outputs: + release: ${{ steps.by-tag.outputs.release }} + latest-release: ${{ steps.latest.outputs.latest-release }} + docker-tag: ${{ steps.docker.outputs.docker-tag }} + gh-docker-tag: ${{ steps.docker.outputs.gh-docker-tag }} + lowercase-repo: ${{ steps.var.outputs.lowercase-repo }} + rc-dockerfile: '${{ github.workspace }}/apps/meteor/.docker/Dockerfile' + rc-docker-tag: '${{ steps.docker.outputs.gh-docker-tag }}.official' + rc-dockerfile-alpine: '${{ github.workspace }}/apps/meteor/.docker/Dockerfile.alpine' + rc-docker-tag-alpine: '${{ steps.docker.outputs.gh-docker-tag }}.alpine' + node-version: ${{ steps.var.outputs.node-version }} + # this is 100% intentional, secrets are not available for forks, so ee-tests will always fail + # to avoid this, we are using a dummy license, expiring at 2025-06-31 + enterprise-license: X/XumwIkgwQuld0alWKt37lVA90XjKOrfiMvMZ0/RtqsMtrdL9GoAk+4jXnaY1b2ePoG7XSzGhuxEDxFKIWJK3hIKGNTvrd980LgH5sM5+1T4P42ivSpd8UZi0bwjJkCFLIu9RozzYwslGG0IehMxe0S6VjcO0UYlUJtbMCBHuR2WmTAmO6YVU3ln+pZCbrPFaTPSS1RovhKaNCNkZwIx/CLWW8UTXUuFV/ML4PbKKVoa5nvvJwPeatgL7UCnlSD90lfCiiuikpzj/Y/JLkIL6velFbwNxsrxg9iRJ2k0sKheMMSmlTiGzSvZUm+na5WQq91aKGncih+DmaEZA7QGrjp4eoA0dqTk6OmItsy0fHmQhvZIOKNMeO7vNQiLbaSV6rqibrzu7WPpeIvsvL57T1h37USoCSB6+jDqkzdfoqIpz8BxTiJDj1d8xGPJFVrgxoqQqkj9qIP/gCaEz5DF39QFv5sovk4yK2O8fEQYod2d14V9yECYl4szZPMk1IBfCAC2w7czWGHHFonhL+CQGT403y5wmDmnsnjlCqMKF72odqfTPTI8XnCvJDriPMWohnQEAGtTTyciAhNokx/mjAVJ4NeZPcsbm4BjhvJvnjxx/BhYhBBTNWPaCSZzocfrGUj9Z+ZA7BEz+xAFQyGDx3xRzqIXfT0G7w8fvgYJMU= + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + package.json + sparse-checkout-cone-mode: false + ref: ${{ github.ref }} + + - id: var + run: | + LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]") + + echo "LOWERCASE_REPOSITORY: ${LOWERCASE_REPOSITORY}" + echo "lowercase-repo=${LOWERCASE_REPOSITORY}" >> $GITHUB_OUTPUT + + NODE_VERSION=$(node -p "require('./package.json').engines.node") + echo "NODE_VERSION: ${NODE_VERSION}" + echo "node-version=${NODE_VERSION}" >> $GITHUB_OUTPUT + + - id: by-tag + run: | + if echo "$GITHUB_REF_NAME" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' ; then + RELEASE="latest" + elif echo "$GITHUB_REF_NAME" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$' ; then + RELEASE="release-candidate" + fi + echo "RELEASE: ${RELEASE}" + echo "release=${RELEASE}" >> $GITHUB_OUTPUT + + - id: latest + run: | + LATEST_RELEASE="$( + git -c 'versionsort.suffix=-' ls-remote -t --exit-code --refs --sort=-v:refname "https://github.com/$GITHUB_REPOSITORY" '*' | + awk -F/ '$NF !~ /rc|beta/ { print $NF; exit }' + )" + echo "LATEST_RELEASE: ${LATEST_RELEASE}" + echo "latest-release=${LATEST_RELEASE}" >> $GITHUB_OUTPUT + + - id: docker + run: | + if [[ '${{ github.event_name }}' == 'pull_request' ]]; then + DOCKER_TAG="pr-${{ github.event.number }}" + else + DOCKER_TAG="gh-${{ github.run_id }}" + fi + echo "DOCKER_TAG: ${DOCKER_TAG}" + echo "gh-docker-tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT + + build: + name: 📦 Meteor Build - coverage + needs: [release-versions, packages-build] + runs-on: ubuntu-20.04 + + steps: + - name: Collect Workflow Telemetry + uses: catchpoint/workflow-telemetry-action@v2 + with: + theme: dark + job_summary: true + comment_on_pr: false + - name: Github Info + run: | + echo "GITHUB_ACTION: $GITHUB_ACTION" + echo "GITHUB_ACTOR: $GITHUB_ACTOR" + echo "GITHUB_REF: $GITHUB_REF" + echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF" + echo "GITHUB_BASE_REF: $GITHUB_BASE_REF" + echo "github.event_name: ${{ github.event_name }}" + cat $GITHUB_EVENT_PATH + + - uses: actions/checkout@v4 + + - uses: ./.github/actions/meteor-build + with: + node-version: ${{ needs.release-versions.outputs.node-version }} + coverage: ${{ github.event_name != 'release' }} + + checks: + needs: [release-versions, packages-build] + + name: 🔎 Code Check + uses: ./.github/workflows/ci-code-check.yml + with: + node-version: ${{ needs.release-versions.outputs.node-version }} + + build-docker-preview: + name: 🚢 Build Docker Image (preview) + runs-on: ubuntu-20.04 + needs: [build, checks, release-versions] + if: github.event_name == 'release' || github.ref == 'refs/heads/develop' + steps: + - uses: actions/checkout@v4 + + - name: Restore build + uses: actions/download-artifact@v3 + with: + name: build + path: /tmp/build + + - name: Unpack build + run: | + cd /tmp/build + tar xzf Rocket.Chat.tar.gz + rm Rocket.Chat.tar.gz + + - name: Build Docker image + id: build-docker-image-preview + uses: ./.github/actions/build-docker-image + with: + root-dir: /tmp/build + docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }} + release: preview + username: ${{ secrets.CR_USER }} + password: ${{ secrets.CR_PAT }} + registry: ${{ secrets.CR_REGISTRY }} + namespace: ${{ secrets.CR_NAMESPACE }} \ No newline at end of file