61 lines
2.2 KiB
YAML
61 lines
2.2 KiB
YAML
name: Jan Web Server build image and push to Harbor Registry
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev-web
|
|
pull_request:
|
|
branches:
|
|
- dev-web
|
|
|
|
jobs:
|
|
build-and-preview:
|
|
runs-on: [ubuntu-24-04-docker]
|
|
env:
|
|
MENLO_PLATFORM_BASE_URL: "https://api-dev.menlo.ai/v1"
|
|
permissions:
|
|
pull-requests: write
|
|
contents: write
|
|
steps:
|
|
- name: Checkout source repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Harbor Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: registry.menlo.ai
|
|
username: ${{ secrets.HARBOR_USERNAME }}
|
|
password: ${{ secrets.HARBOR_PASSWORD }}
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
|
|
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
|
|
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
|
|
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
|
|
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
|
|
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
|
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
|
|
&& sudo apt update
|
|
sudo apt-get install -y jq gettext
|
|
|
|
- name: Set image tag
|
|
id: vars
|
|
run: |
|
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
|
IMAGE_TAG="web:preview-${{ github.sha }}"
|
|
else
|
|
IMAGE_TAG="web:dev-${{ github.sha }}"
|
|
fi
|
|
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
|
echo "FULL_IMAGE=registry.menlo.ai/jan-server/${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build docker image
|
|
run: |
|
|
docker build --build-arg MENLO_PLATFORM_BASE_URL=${{ env.MENLO_PLATFORM_BASE_URL }} -t ${{ steps.vars.outputs.FULL_IMAGE }} .
|
|
|
|
- name: Push docker image
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
docker push ${{ steps.vars.outputs.FULL_IMAGE }}
|