Skip to content

Commit

Permalink
chore(ci): test
Browse files Browse the repository at this point in the history
  • Loading branch information
zsq1234 committed Aug 5, 2024
1 parent 696c20f commit 28be1d3
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 161 deletions.
38 changes: 25 additions & 13 deletions .github/actions/build-docker-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ inputs:
required: false
password:
required: false
aliyun:
required: false
default: "no"

outputs:
image-name:
Expand Down Expand Up @@ -69,30 +72,39 @@ runs:
fi;
echo "Build ${{ inputs.release }} Docker image"
docker build -t $IMAGE_NAME .
# docker build -t $IMAGE_NAME .
echo "image-name-base=${IMAGE_NAME_BASE}" >> $GITHUB_OUTPUT
echo "image-name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop'
if: (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop') && inputs.aliyun == 'no'
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- name: Publish image
shell: bash
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop'
run: |
echo "Push Docker image: ${{ steps.build-image.outputs.image-name }}"
- name: Login to Aliyun Container Registry (ACR)
uses: aliyun/acr-login@v1
if: (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop') && inputs.aliyun == 'yes'
with:
login-server: ${{ inputs.registry }}
region-id: cn-shenzhen
username: "${{ inputs.username }}"
password: "${{ inputs.password }}"

# - name: Publish image
# shell: bash
# if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop'
# run: |
# echo "Push Docker image: ${{ steps.build-image.outputs.image-name }}"

docker push ${{ steps.build-image.outputs.image-name }}
# docker push ${{ steps.build-image.outputs.image-name }}

if [[ '${{ inputs.release }}' = 'official' ]]; then
echo "Push release official without variant"
# if [[ '${{ inputs.release }}' = 'official' ]]; then
# echo "Push release official without variant"

docker tag ${{ steps.build-image.outputs.image-name }} ${{ steps.build-image.outputs.image-name-base }}
docker push ${{ steps.build-image.outputs.image-name-base }}
fi;
# docker tag ${{ steps.build-image.outputs.image-name }} ${{ steps.build-image.outputs.image-name-base }}
# docker push ${{ steps.build-image.outputs.image-name-base }}
# fi;
297 changes: 149 additions & 148 deletions .github/workflows/ci-univer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,161 +8,161 @@ concurrency:
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
packages-build:
name: 📦 Build Packages
needs: [release-versions]
runs-on: ubuntu-20.04
steps:
- 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
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 4

- uses: actions/checkout@v4

- name: Setup NodeJS
uses: ./.github/actions/setup-node
with:
node-version: ${{ needs.release-versions.outputs.node-version }}
cache-modules: true
install: true

- name: Cache vite
uses: actions/cache@v3
with:
path: ./node_modules/.vite
key: vite-local-cache-${{ runner.OS }}-${{ hashFiles('package.json') }}
restore-keys: |
vite-local-cache-${{ runner.os }}-
- uses: dtinth/setup-github-actions-caching-for-turbo@v1

- name: Build Rocket.Chat Packages
run: yarn build

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' }}
# 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

# packages-build:
# name: 📦 Build Packages
# needs: [release-versions]
# runs-on: ubuntu-20.04
# steps:
# - 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

# - name: Set Swap Space
# uses: pierotofy/set-swap-space@master
# with:
# swap-size-gb: 4

# - uses: actions/checkout@v4

# - name: Setup NodeJS
# uses: ./.github/actions/setup-node
# with:
# node-version: ${{ needs.release-versions.outputs.node-version }}
# cache-modules: true
# install: true

# - name: Cache vite
# uses: actions/cache@v3
# with:
# path: ./node_modules/.vite
# key: vite-local-cache-${{ runner.OS }}-${{ hashFiles('package.json') }}
# restore-keys: |
# vite-local-cache-${{ runner.os }}-

# - uses: dtinth/setup-github-actions-caching-for-turbo@v1

# - name: Build Rocket.Chat Packages
# run: yarn build

# 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' }}

build-docker-preview:
name: 🚢 Build Docker Image (preview)
runs-on: ubuntu-20.04
needs: [build, release-versions]
# needs: [build, release-versions]
if: github.event_name == 'release' || github.ref == 'refs/heads/develop'
steps:
- uses: actions/checkout@v4
# - uses: actions/checkout@v4

- name: Restore build
uses: actions/download-artifact@v3
with:
name: build
path: /tmp/build
# - 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: 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
Expand All @@ -174,4 +174,5 @@ jobs:
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
registry: ${{ secrets.CR_REGISTRY }}
namespace: ${{ secrets.CR_NAMESPACE }}
namespace: ${{ secrets.CR_NAMESPACE }}
aliyun: 'yes'

0 comments on commit 28be1d3

Please sign in to comment.