Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into refa…
Browse files Browse the repository at this point in the history
…ctor/favicon
  • Loading branch information
tassoevan committed Jun 21, 2022
2 parents 6267737 + 63d4e30 commit 7c85d98
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/actions/build-docker-image-service/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ runs:
echo "::set-output name=image-name::${IMAGE_NAME}"
- name: Login to GitHub Container Registry
if: github.event.pull_request.head.repo.full_name == github.repository || 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'
uses: docker/login-action@v2
with:
registry: ghcr.io
Expand All @@ -62,7 +62,7 @@ runs:

- name: Publish image
shell: bash
if: github.event.pull_request.head.repo.full_name == github.repository || 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'
run: |
echo "Push Docker image: ${{ steps.build-image.outputs.image-name }}"
Expand Down
23 changes: 13 additions & 10 deletions .github/actions/build-docker-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@ runs:
cd ${{ inputs.root-dir }}
LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]")
IMAGE_NAME="rocket.chat"
if [[ '${{ inputs.release }}' = 'preview' ]]; then
IMAGE_NAME="${IMAGE_NAME}.preview"
fi;
IMAGE_NAME="ghcr.io/${LOWERCASE_REPOSITORY}/${IMAGE_NAME}:${{ inputs.docker-tag }}"
if [[ '${{ inputs.release }}' = 'alpine' ]]; then
IMAGE_NAME="${IMAGE_NAME}.${{ inputs.release }}"
fi;
IMAGE_NAME_BASE="ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${{ inputs.docker-tag }}"
IMAGE_NAME="${IMAGE_NAME_BASE}.${{ inputs.release }}"
echo "Build Docker image ${IMAGE_NAME}"
Expand All @@ -66,10 +61,11 @@ runs:
echo "Build ${{ inputs.release }} Docker image"
docker build -t $IMAGE_NAME .
echo "::set-output name=image-name-base::${IMAGE_NAME_BASE}"
echo "::set-output name=image-name::${IMAGE_NAME}"
- 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'
uses: docker/login-action@v2
with:
registry: ghcr.io
Expand All @@ -78,8 +74,15 @@ runs:

- 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')
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 }}
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;
82 changes: 48 additions & 34 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
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 }}
steps:
- id: by-tag
run: |
Expand All @@ -50,13 +51,11 @@ jobs:
run: |
if [[ '${{ github.event_name }}' == 'pull_request' ]]; then
DOCKER_TAG="pr-${{ github.event.number }}"
elif echo "$GITHUB_REF_NAME" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+' ; then
DOCKER_TAG="$GITHUB_REF_NAME"
elif [[ $GITHUB_REF == 'refs/heads/develop' ]]; then
DOCKER_TAG="develop"
else
DOCKER_TAG="gh-${{ github.run_id }}"
fi
echo "DOCKER_TAG: ${DOCKER_TAG}"
echo "::set-output name=docker-tag::${DOCKER_TAG}"
echo "::set-output name=gh-docker-tag::${DOCKER_TAG}"
build:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -219,7 +218,7 @@ jobs:
uses: ./.github/actions/build-docker-image
with:
root-dir: /tmp/build
docker-tag: ${{ needs.release-versions.outputs.docker-tag }}
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
release: preview
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
Expand Down Expand Up @@ -292,7 +291,7 @@ jobs:
uses: ./.github/actions/build-docker-image
with:
root-dir: /tmp/build
docker-tag: ${{ needs.release-versions.outputs.docker-tag }}
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
release: official
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
Expand All @@ -303,7 +302,7 @@ jobs:
uses: ./.github/actions/build-docker-image
with:
root-dir: /tmp/build
docker-tag: ${{ needs.release-versions.outputs.docker-tag }}
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
release: alpine
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
Expand All @@ -313,11 +312,11 @@ jobs:
run: |
LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]")
IMAGE_TAG="${{ needs.release-versions.outputs.docker-tag }}"
# test alpine image on mongo 5.0 (no special reason to be mongo 5.0 but we need to test alpine at least once)
if [[ '${{ matrix.mongodb-version }}' = '5.0' ]]; then
IMAGE_TAG="${IMAGE_TAG}.alpine"
IMAGE_TAG="${{ needs.release-versions.outputs.gh-docker-tag }}.alpine"
else
IMAGE_TAG="${{ needs.release-versions.outputs.gh-docker-tag }}.official"
fi;
IMAGE_NAME="ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${IMAGE_TAG}"
Expand Down Expand Up @@ -445,42 +444,64 @@ jobs:
- name: Unit Test
run: yarn testunit

- name: Restore build
uses: actions/download-artifact@v2
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
uses: ./.github/actions/build-docker-image
with:
root-dir: /tmp/build
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
release: official
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}

- name: "Build Docker image: account"
uses: ./.github/actions/build-docker-image-service
with:
docker-tag: ${{ needs.release-versions.outputs.docker-tag }}
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
service: account
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}

- name: "Build Docker image: authorization"
uses: ./.github/actions/build-docker-image-service
with:
docker-tag: ${{ needs.release-versions.outputs.docker-tag }}
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
service: authorization
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}

- name: "Build Docker image: ddp-streamer"
uses: ./.github/actions/build-docker-image-service
with:
docker-tag: ${{ needs.release-versions.outputs.docker-tag }}
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
service: ddp-streamer
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}

- name: "Build Docker image: presence"
uses: ./.github/actions/build-docker-image-service
with:
docker-tag: ${{ needs.release-versions.outputs.docker-tag }}
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
service: presence
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}

- name: "Build Docker image: stream-hub"
uses: ./.github/actions/build-docker-image-service
with:
docker-tag: ${{ needs.release-versions.outputs.docker-tag }}
docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
service: stream-hub
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
Expand Down Expand Up @@ -509,7 +530,7 @@ jobs:
-e ENTERPRISE_LICENSE="${{ secrets.ENTERPRISE_LICENSE }}" \
-e SKIP_PROCESS_EVENT_REGISTRATION=true \
--label 'traefik.http.routers.rocketchat.rule=PathPrefix(`/`)' \
ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${{ needs.release-versions.outputs.docker-tag }}
ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${{ needs.release-versions.outputs.gh-docker-tag }}.official
# spin up all micro services
docker run --name ddp-streamer -d \
Expand All @@ -522,7 +543,7 @@ jobs:
-e MOLECULER_LOG_LEVEL=info \
--label 'traefik.http.services.ddp-streamer.loadbalancer.server.port=4000' \
--label 'traefik.http.routers.ddp-streamer.rule=PathPrefix(`/websocket`) || PathPrefix(`/sockjs`)' \
ghcr.io/${LOWERCASE_REPOSITORY}/ddp-streamer-service:${{ needs.release-versions.outputs.docker-tag }}
ghcr.io/${LOWERCASE_REPOSITORY}/ddp-streamer-service:${{ needs.release-versions.outputs.gh-docker-tag }}
- name: "Start service: stream-hub"
run: |
Expand All @@ -535,7 +556,7 @@ jobs:
-e MONGO_OPLOG_URL=mongodb://mongo:27017/local \
-e TRANSPORTER=nats://nats:4222 \
-e MOLECULER_LOG_LEVEL=info \
ghcr.io/${LOWERCASE_REPOSITORY}/stream-hub-service:${{ needs.release-versions.outputs.docker-tag }}
ghcr.io/${LOWERCASE_REPOSITORY}/stream-hub-service:${{ needs.release-versions.outputs.gh-docker-tag }}
until echo "$(docker logs stream-hub)" | grep -q "NetworkBroker started successfully"; do
echo "Waiting 'stream-hub' to start up"
Expand All @@ -554,7 +575,7 @@ jobs:
-e MONGO_OPLOG_URL=mongodb://mongo:27017/local \
-e TRANSPORTER=nats://nats:4222 \
-e MOLECULER_LOG_LEVEL=info \
ghcr.io/${LOWERCASE_REPOSITORY}/account-service:${{ needs.release-versions.outputs.docker-tag }}
ghcr.io/${LOWERCASE_REPOSITORY}/account-service:${{ needs.release-versions.outputs.gh-docker-tag }}
until echo "$(docker logs account)" | grep -q "NetworkBroker started successfully"; do
echo "Waiting 'account' to start up"
Expand All @@ -573,7 +594,7 @@ jobs:
-e MONGO_OPLOG_URL=mongodb://mongo:27017/local \
-e TRANSPORTER=nats://nats:4222 \
-e MOLECULER_LOG_LEVEL=info \
ghcr.io/${LOWERCASE_REPOSITORY}/authorization-service:${{ needs.release-versions.outputs.docker-tag }}
ghcr.io/${LOWERCASE_REPOSITORY}/authorization-service:${{ needs.release-versions.outputs.gh-docker-tag }}
until echo "$(docker logs authorization)" | grep -q "NetworkBroker started successfully"; do
echo "Waiting 'authorization' to start up"
Expand All @@ -592,7 +613,7 @@ jobs:
-e MONGO_OPLOG_URL=mongodb://mongo:27017/local \
-e TRANSPORTER=nats://nats:4222 \
-e MOLECULER_LOG_LEVEL=info \
ghcr.io/${LOWERCASE_REPOSITORY}/presence-service:${{ needs.release-versions.outputs.docker-tag }}
ghcr.io/${LOWERCASE_REPOSITORY}/presence-service:${{ needs.release-versions.outputs.gh-docker-tag }}
until echo "$(docker logs presence)" | grep -q "NetworkBroker started successfully"; do
echo "Waiting 'presence' to start up"
Expand Down Expand Up @@ -803,15 +824,8 @@ jobs:
id: gh-docker
run: |
LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]")
IMAGE_NAME="rocket.chat"
if [[ '${{ matrix.release }}' = 'preview' ]]; then
IMAGE_NAME="${IMAGE_NAME}.preview"
fi;
GH_IMAGE_NAME="ghcr.io/${LOWERCASE_REPOSITORY}/${IMAGE_NAME}:${{ needs.release-versions.outputs.docker-tag }}"
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
GH_IMAGE_NAME="${IMAGE_NAME}.${{ matrix.release }}"
fi;
GH_IMAGE_NAME="ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${{ needs.release-versions.outputs.gh-docker-tag }}.${{ matrix.release }}"
echo "GH_IMAGE_NAME: $GH_IMAGE_NAME"
Expand All @@ -838,7 +852,7 @@ jobs:
echo "DOCKER_TAG: $DOCKER_TAG"
# tag and push the specific tag version
docker tag $GH_IMAGE_NAME $IMAGE_NAME:$DOCKER_TAG
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$DOCKER_TAG
docker push $IMAGE_NAME:$DOCKER_TAG
if [[ $GITHUB_REF == refs/tags/* ]]; then
Expand All @@ -852,11 +866,11 @@ jobs:
if [[ $RELEASE == 'latest' ]]; then
if [[ '${{ needs.release-versions.outputs.latest-release }}' == $GITHUB_REF_NAME ]]; then
docker tag $IMAGE_NAME:$DOCKER_TAG $IMAGE_NAME:$RELEASE
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$RELEASE
docker push $IMAGE_NAME:$RELEASE
fi
else
docker tag $IMAGE_NAME:$DOCKER_TAG $IMAGE_NAME:$RELEASE
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$RELEASE
docker push $IMAGE_NAME:$RELEASE
fi
fi
Expand Down Expand Up @@ -887,7 +901,7 @@ jobs:
run: |
LOWERCASE_REPOSITORY=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]")
IMAGE_TAG="${{ needs.release-versions.outputs.docker-tag }}"
IMAGE_TAG="${{ needs.release-versions.outputs.gh-docker-tag }}"
GH_IMAGE_NAME="ghcr.io/${LOWERCASE_REPOSITORY}/${{ matrix.service }}-service:${IMAGE_TAG}"
Expand Down

0 comments on commit 7c85d98

Please sign in to comment.