Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/fork-ghcr-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Fork Publish GHCR Image

on:
push:
branches:
- main
- lab
workflow_dispatch:
inputs:
channel:
description: "Channel tag to publish, for example lab or main"
required: true
default: "lab"
type: string
push_latest:
description: "Also publish the latest tag"
required: true
default: false
type: boolean

permissions:
contents: read
packages: write

concurrency:
group: fork-ghcr-${{ github.ref }}
cancel-in-progress: false

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Check out
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- name: Resolve image metadata
id: meta
shell: bash
run: |
repo="ghcr.io/${GITHUB_REPOSITORY,,}"

if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
channel="${{ github.event.inputs.channel }}"
else
channel="${GITHUB_REF_NAME}"
fi

short_sha="${GITHUB_SHA::7}"
version="${channel}-$(date +'%Y%m%d')-${short_sha}"

if [ ! -s VERSION ]; then
echo "${version}" > VERSION
fi

echo "repo=${repo}" >> "${GITHUB_OUTPUT}"
echo "channel=${channel}" >> "${GITHUB_OUTPUT}"
echo "version=${version}" >> "${GITHUB_OUTPUT}"

- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3

- name: Log in to GHCR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.channel }}
${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.version }}
${{ steps.meta.outputs.repo }}:sha-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: mode=max
sbom: true

- name: Publish latest tag
if: ${{ github.ref_name == 'main' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_latest == 'true') }}
run: |
docker buildx imagetools create \
-t ${{ steps.meta.outputs.repo }}:latest \
${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.version }}
52 changes: 52 additions & 0 deletions .github/workflows/fork-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Fork Verify

on:
push:
pull_request:

permissions:
contents: read

concurrency:
group: fork-verify-${{ github.ref }}
cancel-in-progress: true

jobs:
verify:
runs-on: ubuntu-latest

steps:
- name: Check out
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- name: Resolve build version
run: |
if [ ! -s VERSION ]; then
echo "dev-${GITHUB_SHA::7}" > VERSION
fi

- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: latest

- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: "1.26.2"

- name: Build frontend
env:
CI: ""
run: |
cd web
bun install
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION="$(cat ../VERSION)" bun run build

- name: Run Go tests
run: |
go mod download
go test ./... -count=1

- name: Verify Docker build
run: docker build -t new-api-fork:verify .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ data/
.gomodcache/
.gocache-temp
.gopath
deploy/lab/.env
deploy/lab/runtime/
1 change: 1 addition & 0 deletions constant/context_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
ContextKeyChannelIsMultiKey ContextKey = "channel_is_multi_key"
ContextKeyChannelMultiKeyIndex ContextKey = "channel_multi_key_index"
ContextKeyChannelKey ContextKey = "channel_key"
ContextKeyGovernorAttempt ContextKey = "governor_attempt"

ContextKeyAutoGroup ContextKey = "auto_group"
ContextKeyAutoGroupIndex ContextKey = "auto_group_index"
Expand Down
Loading
Loading