Skip to content

💄 ui: add smoke-test monitoring metadata to site status cards #24

💄 ui: add smoke-test monitoring metadata to site status cards

💄 ui: add smoke-test monitoring metadata to site status cards #24

# ---------------------------------
# This workflow is used to build overleaf image automatically
#
# Published at:
# ghcr.io/m0rtzz/overleaf/ops
#
# ---------------------------------
name: Build Operations Image
on:
push:
branches:
- server-pro
pull_request:
branches:
- server-pro
workflow_dispatch:
permissions:
contents: read
packages: write
env:
DOCKER_REGISTRY: ghcr.io
IMAGE_NAME: m0rtzz/overleaf
jobs:
build-image:
runs-on: ubuntu-latest
steps:
# If the event is a pull request, checkout the head sha of the PR
- name: "Checkout Current Repository"
uses: actions/checkout@main
with:
fetch-depth: 0
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
- name: "Login to GHCR"
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# --- We need to sync package-lock.json/i18 to ensure consistency ---
- name: "Sync package-lock.json And Prepare .dockerignore"
run: |
docker run --rm -v "$(pwd)":/workspace -w /workspace node:22.18.0 npm install --package-lock-only --ignore-scripts
docker run --rm -v "$(pwd)/services/web/":/overleaf/services/web -w /overleaf/services/web ghcr.io/m0rtzz/overleaf/dev:webpack npm run extract-translations
cd ./server-ce/
cp .dockerignore ../
# --- Set up Docker ---
# See: https://docs.docker.com/build/ci/github-actions/multi-platform/
- name: Set up Docker (enable containerd image store)
uses: docker/setup-docker-action@v4
with:
daemon-config: |
{
"features": {
"containerd-snapshotter": true
}
}
- name: Set up Buildx (docker driver)
uses: docker/setup-buildx-action@v3
with:
driver: docker
# --- Build Base Image ---
- name: "Build base image (hash cache)"
uses: docker/build-push-action@v6
with:
context: ./
file: ./server-ce/Dockerfile-base
load: true
push: false
pull: true
tags: |
sharelatex/sharelatex-base:latest
cache-from: type=gha,scope=base-${{ hashFiles('server-ce/Dockerfile-base') }}
cache-to: type=gha,mode=max,scope=base-${{ hashFiles('server-ce/Dockerfile-base') }}
provenance: false
sbom: false
# --- End of Base Image ---
# --- Build Server Image ---
- name: "Get MONOREPO_REVISION"
id: vars
run: echo "MONOREPO_REVISION=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: "Build Server image"
uses: docker/build-push-action@v6
with:
context: ./
file: ./server-ce/Dockerfile
load: true
push: false
pull: false
tags: |
sharelatex/sharelatex:latest
labels: |
com.m0rtzz.overleaf.ops.revision=${{ steps.vars.outputs.MONOREPO_REVISION }}
# We don't want -${{ github.ref_name }} limit, just more cache hit
cache-from: type=gha,scope=ops
cache-to: type=gha,mode=max,scope=ops
provenance: false
sbom: false
# --- End of Server Image ---
# --- Push Server Image ---
- name: "ReTag Docker Image And Push"
run: |
cd ./server-ce
github_short_sha=$(echo ${{ github.sha }} | head -c7)
if [ "${{ github.event_name }}" = "pull_request" ]; then
github_short_sha=$(echo ${{ github.event.pull_request.head.sha }} | head -c7)
fi
tag=$(TZ='Asia/Shanghai' date +'%Y%m%d%H%M')-$github_short_sha
echo "Building tag: $tag"
docker tag sharelatex/sharelatex:latest ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}/ops:latest
docker tag sharelatex/sharelatex:latest ${{env.DOCKER_REGISTRY}}/${{env.IMAGE_NAME}}/ops:$tag
docker push ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}/ops:latest
docker push ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}/ops:$tag
# --- Retention Policy: Delete old images ---
- name: Delete old images
uses: snok/container-retention-policy@v2
with:
image-names: overleaf/ops*
cut-off: A week ago UTC+8
account-type: personal
untagged-only: false
token: ${{ secrets.GHCR_PAT }}