Compare commits
2 Commits
ad3af5bd56
...
2645d2afe5
| Author | SHA1 | Date | |
|---|---|---|---|
| 2645d2afe5 | |||
| d88e202bb3 |
23
.gitea/workflows/deploy.yml
Normal file
23
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: Deploy Production
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Unit tests
|
||||||
|
run: cd frontend && npm ci && npm run test:unit
|
||||||
|
|
||||||
|
- name: Build & Deploy
|
||||||
|
run: |
|
||||||
|
rsync -az --exclude node_modules --exclude .git --exclude .venv . oci:~/oil-calculator/
|
||||||
|
ssh oci "
|
||||||
|
cd ~/oil-calculator &&
|
||||||
|
docker build -t registry.oci.euphon.net/oil-calculator:latest . &&
|
||||||
|
docker push registry.oci.euphon.net/oil-calculator:latest &&
|
||||||
|
sudo k3s kubectl rollout restart deploy/oil-calculator -n oil-calculator
|
||||||
|
"
|
||||||
190
.gitea/workflows/preview.yml
Normal file
190
.gitea/workflows/preview.yml
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
name: PR Preview
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened, closed]
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: registry.oci.euphon.net
|
||||||
|
BASE_DOMAIN: oil.oci.euphon.net
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy-preview:
|
||||||
|
if: github.event.action != 'closed'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Unit tests
|
||||||
|
run: cd frontend && npm ci && npm run test:unit
|
||||||
|
|
||||||
|
- name: Deploy Preview Environment
|
||||||
|
run: |
|
||||||
|
PR_ID="${{ github.event.pull_request.number }}"
|
||||||
|
NS="oil-pr-${PR_ID}"
|
||||||
|
HOST="pr-${PR_ID}.${BASE_DOMAIN}"
|
||||||
|
IMAGE="${REGISTRY}/oil-calculator:pr-${PR_ID}"
|
||||||
|
|
||||||
|
# Sync source to oci build server
|
||||||
|
rsync -az --exclude node_modules --exclude .git --exclude .venv \
|
||||||
|
. oci:/tmp/oil-pr-${PR_ID}-build/
|
||||||
|
|
||||||
|
ssh oci bash -s "${PR_ID}" "${NS}" "${HOST}" "${IMAGE}" << 'DEPLOY_SCRIPT'
|
||||||
|
set -e
|
||||||
|
PR_ID="$1"; NS="$2"; HOST="$3"; IMAGE="$4"
|
||||||
|
|
||||||
|
cd /tmp/oil-pr-${PR_ID}-build
|
||||||
|
|
||||||
|
# Copy production DB into build context so it's baked into image
|
||||||
|
PROD_POD=$(sudo k3s kubectl get pods -n oil-calculator -l app=oil-calculator \
|
||||||
|
--field-selector=status.phase=Running -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || echo "")
|
||||||
|
if [ -n "$PROD_POD" ]; then
|
||||||
|
sudo k3s kubectl cp "oil-calculator/${PROD_POD}:/data/oil_calculator.db" /tmp/pr-${PR_ID}.db
|
||||||
|
mkdir -p data
|
||||||
|
cp /tmp/pr-${PR_ID}.db data/oil_calculator.db
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build image (with DB baked in)
|
||||||
|
cat > Dockerfile.preview << 'DEOF'
|
||||||
|
FROM node:20-slim AS frontend-build
|
||||||
|
WORKDIR /build
|
||||||
|
COPY frontend/package.json frontend/package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY frontend/ ./
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM python:3.12-slim
|
||||||
|
WORKDIR /app
|
||||||
|
COPY backend/requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
COPY backend/ ./backend/
|
||||||
|
COPY --from=frontend-build /build/dist ./frontend/
|
||||||
|
# Bake production DB copy into image
|
||||||
|
COPY data/oil_calculator.db /data/oil_calculator.db
|
||||||
|
ENV DB_PATH=/data/oil_calculator.db
|
||||||
|
ENV FRONTEND_DIR=/app/frontend
|
||||||
|
EXPOSE 8000
|
||||||
|
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
|
DEOF
|
||||||
|
|
||||||
|
docker build -f Dockerfile.preview -t "${IMAGE}" .
|
||||||
|
docker push "${IMAGE}"
|
||||||
|
|
||||||
|
# Create namespace
|
||||||
|
sudo k3s kubectl create namespace "${NS}" --dry-run=client -o yaml | sudo k3s kubectl apply -f -
|
||||||
|
|
||||||
|
# Copy regcred from production namespace
|
||||||
|
sudo k3s kubectl get secret regcred -n oil-calculator -o json | \
|
||||||
|
sed "s/\"namespace\":\"oil-calculator\"/\"namespace\":\"${NS}\"/" | \
|
||||||
|
sudo k3s kubectl apply -f -
|
||||||
|
|
||||||
|
# Deploy pod + service + ingress (no PVC needed, DB is in image)
|
||||||
|
cat << EOYAML | sudo k3s kubectl apply -f -
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: oil-calculator
|
||||||
|
namespace: ${NS}
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: oil-calculator
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: oil-calculator
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: regcred
|
||||||
|
containers:
|
||||||
|
- name: app
|
||||||
|
image: ${IMAGE}
|
||||||
|
ports:
|
||||||
|
- containerPort: 8000
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 50m
|
||||||
|
memory: 64Mi
|
||||||
|
limits:
|
||||||
|
cpu: 500m
|
||||||
|
memory: 256Mi
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: oil-calculator
|
||||||
|
namespace: ${NS}
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: oil-calculator
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 8000
|
||||||
|
---
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: oil-calculator
|
||||||
|
namespace: ${NS}
|
||||||
|
annotations:
|
||||||
|
traefik.ingress.kubernetes.io/router.tls.certresolver: le
|
||||||
|
spec:
|
||||||
|
ingressClassName: traefik
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- ${HOST}
|
||||||
|
rules:
|
||||||
|
- host: ${HOST}
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: oil-calculator
|
||||||
|
port:
|
||||||
|
number: 80
|
||||||
|
EOYAML
|
||||||
|
|
||||||
|
# Wait for rollout
|
||||||
|
sudo k3s kubectl rollout status deploy/oil-calculator -n "${NS}" --timeout=120s
|
||||||
|
|
||||||
|
# Cleanup build dir
|
||||||
|
rm -rf /tmp/oil-pr-${PR_ID}-build /tmp/pr-${PR_ID}.db
|
||||||
|
|
||||||
|
echo "Preview deployed: https://${HOST}"
|
||||||
|
DEPLOY_SCRIPT
|
||||||
|
|
||||||
|
- name: Comment PR with preview URL
|
||||||
|
run: |
|
||||||
|
PR_ID="${{ github.event.pull_request.number }}"
|
||||||
|
HOST="pr-${PR_ID}.${BASE_DOMAIN}"
|
||||||
|
curl -s -X POST \
|
||||||
|
"https://git.euphon.cloud/api/v1/repos/${{ github.repository }}/issues/${PR_ID}/comments" \
|
||||||
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"body\": \"🚀 Preview deployed: https://${HOST}\n\nDB is a copy of production. Changes here won't affect prod.\"}"
|
||||||
|
|
||||||
|
teardown-preview:
|
||||||
|
if: github.event.action == 'closed'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Teardown Preview Environment
|
||||||
|
run: |
|
||||||
|
PR_ID="${{ github.event.pull_request.number }}"
|
||||||
|
NS="oil-pr-${PR_ID}"
|
||||||
|
IMAGE="${REGISTRY}/oil-calculator:pr-${PR_ID}"
|
||||||
|
|
||||||
|
ssh oci "
|
||||||
|
sudo k3s kubectl delete namespace ${NS} --ignore-not-found
|
||||||
|
docker rmi ${IMAGE} 2>/dev/null || true
|
||||||
|
"
|
||||||
|
|
||||||
|
- name: Comment PR
|
||||||
|
run: |
|
||||||
|
PR_ID="${{ github.event.pull_request.number }}"
|
||||||
|
curl -s -X POST \
|
||||||
|
"https://git.euphon.cloud/api/v1/repos/${{ github.repository }}/issues/${PR_ID}/comments" \
|
||||||
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"body\": \"🗑️ Preview environment torn down.\"}"
|
||||||
17
.gitea/workflows/test.yml
Normal file
17
.gitea/workflows/test.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
name: Test
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: cd frontend && npm ci
|
||||||
|
|
||||||
|
- name: Unit tests
|
||||||
|
run: cd frontend && npm run test:unit
|
||||||
|
|
||||||
|
- name: Build check
|
||||||
|
run: cd frontend && npm run build
|
||||||
39
frontend/cypress/e2e/price-display.cy.js
Normal file
39
frontend/cypress/e2e/price-display.cy.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
describe('Price Display Regression', () => {
|
||||||
|
it('recipe cards show non-zero prices', () => {
|
||||||
|
cy.visit('/')
|
||||||
|
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||||
|
cy.wait(2000) // wait for oils store to load and re-render
|
||||||
|
|
||||||
|
// Check via .card-price elements which hold the formatted cost
|
||||||
|
cy.get('.card-price').first().invoke('text').then(text => {
|
||||||
|
const match = text.match(/¥\s*(\d+\.?\d*)/)
|
||||||
|
expect(match, 'Card price should contain ¥').to.not.be.null
|
||||||
|
expect(parseFloat(match[1]), 'Price should be > 0').to.be.gt(0)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('oil reference page shows non-zero prices', () => {
|
||||||
|
cy.visit('/oils')
|
||||||
|
cy.get('.oil-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||||
|
cy.wait(500)
|
||||||
|
|
||||||
|
cy.get('.oil-card').first().invoke('text').then(text => {
|
||||||
|
const match = text.match(/¥\s*(\d+\.?\d*)/)
|
||||||
|
expect(match, 'Oil card should contain a price').to.not.be.null
|
||||||
|
expect(parseFloat(match[1])).to.be.gt(0)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('recipe detail shows non-zero total cost', () => {
|
||||||
|
cy.visit('/')
|
||||||
|
cy.get('.recipe-card', { timeout: 10000 }).first().click()
|
||||||
|
cy.wait(1000)
|
||||||
|
|
||||||
|
// Look for any ¥ amount > 0 in the detail overlay
|
||||||
|
cy.get('[class*="overlay"], [class*="detail"]').invoke('text').then(text => {
|
||||||
|
const prices = [...text.matchAll(/¥\s*(\d+\.?\d*)/g)].map(m => parseFloat(m[1]))
|
||||||
|
const nonZero = prices.filter(p => p > 0)
|
||||||
|
expect(nonZero.length, 'Detail should show at least one non-zero price').to.be.gte(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
55
frontend/cypress/e2e/visual-check.cy.js
Normal file
55
frontend/cypress/e2e/visual-check.cy.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
// Quick visual screenshots for manual review before deploy
|
||||||
|
const ADMIN_TOKEN = 'c86ae7afbe10fabe3c1d5e1a7fee74feaadfd5dc7be2ab62'
|
||||||
|
|
||||||
|
describe('Visual Check - Screenshots', () => {
|
||||||
|
it('homepage with recipes', () => {
|
||||||
|
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN) } })
|
||||||
|
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||||
|
cy.wait(1000)
|
||||||
|
cy.screenshot('01-homepage')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('recipe detail overlay', () => {
|
||||||
|
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN) } })
|
||||||
|
cy.get('.recipe-card', { timeout: 10000 }).first().click()
|
||||||
|
cy.wait(1000)
|
||||||
|
cy.screenshot('02-recipe-detail')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('oil reference page', () => {
|
||||||
|
cy.visit('/oils', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN) } })
|
||||||
|
cy.get('.oil-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||||
|
cy.wait(500)
|
||||||
|
cy.screenshot('03-oil-reference')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('manage recipes page', () => {
|
||||||
|
cy.visit('/manage', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN) } })
|
||||||
|
cy.wait(2000)
|
||||||
|
cy.screenshot('04-manage-recipes')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('inventory page', () => {
|
||||||
|
cy.visit('/inventory', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN) } })
|
||||||
|
cy.wait(1500)
|
||||||
|
cy.screenshot('05-inventory')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('check if recipe cards show price > 0', () => {
|
||||||
|
cy.visit('/', { onBeforeLoad(win) { win.localStorage.setItem('oil_auth_token', ADMIN_TOKEN) } })
|
||||||
|
cy.get('.recipe-card', { timeout: 10000 }).should('have.length.gte', 1)
|
||||||
|
// Check if any card shows a non-zero price
|
||||||
|
cy.get('.recipe-card').first().invoke('text').then(text => {
|
||||||
|
cy.log('First card text: ' + text)
|
||||||
|
// Check if it contains a price like ¥ X.XX where X > 0
|
||||||
|
const priceMatch = text.match(/¥\s*(\d+\.?\d*)/)
|
||||||
|
if (priceMatch) {
|
||||||
|
cy.log('Price found: ¥' + priceMatch[1])
|
||||||
|
const price = parseFloat(priceMatch[1])
|
||||||
|
expect(price, 'Recipe card should show price > 0').to.be.gt(0)
|
||||||
|
} else {
|
||||||
|
cy.log('WARNING: No price found on recipe card')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -13,16 +13,16 @@ export const VOLUME_DROPS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useOilsStore = defineStore('oils', () => {
|
export const useOilsStore = defineStore('oils', () => {
|
||||||
const oils = ref(new Map())
|
const oils = ref({})
|
||||||
const oilsMeta = ref(new Map())
|
const oilsMeta = ref({})
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
const oilNames = computed(() =>
|
const oilNames = computed(() =>
|
||||||
[...oils.value.keys()].sort((a, b) => a.localeCompare(b, 'zh'))
|
Object.keys(oils.value).sort((a, b) => a.localeCompare(b, 'zh'))
|
||||||
)
|
)
|
||||||
|
|
||||||
function pricePerDrop(name) {
|
function pricePerDrop(name) {
|
||||||
return oils.value.get(name) || 0
|
return oils.value[name] || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcCost(ingredients) {
|
function calcCost(ingredients) {
|
||||||
@@ -33,7 +33,7 @@ export const useOilsStore = defineStore('oils', () => {
|
|||||||
|
|
||||||
function calcRetailCost(ingredients) {
|
function calcRetailCost(ingredients) {
|
||||||
return ingredients.reduce((sum, ing) => {
|
return ingredients.reduce((sum, ing) => {
|
||||||
const meta = oilsMeta.value.get(ing.oil)
|
const meta = oilsMeta.value[ing.oil]
|
||||||
if (meta && meta.retailPrice && meta.dropCount) {
|
if (meta && meta.retailPrice && meta.dropCount) {
|
||||||
return sum + (meta.retailPrice / meta.dropCount) * ing.drops
|
return sum + (meta.retailPrice / meta.dropCount) * ing.drops
|
||||||
}
|
}
|
||||||
@@ -58,17 +58,17 @@ export const useOilsStore = defineStore('oils', () => {
|
|||||||
// Actions
|
// Actions
|
||||||
async function loadOils() {
|
async function loadOils() {
|
||||||
const data = await api.get('/api/oils')
|
const data = await api.get('/api/oils')
|
||||||
const newOils = new Map()
|
const newOils = {}
|
||||||
const newMeta = new Map()
|
const newMeta = {}
|
||||||
for (const oil of data) {
|
for (const oil of data) {
|
||||||
const ppd = oil.drop_count ? oil.bottle_price / oil.drop_count : 0
|
const ppd = oil.drop_count ? oil.bottle_price / oil.drop_count : 0
|
||||||
newOils.set(oil.name, ppd)
|
newOils[oil.name] = ppd
|
||||||
newMeta.set(oil.name, {
|
newMeta[oil.name] = {
|
||||||
bottlePrice: oil.bottle_price,
|
bottlePrice: oil.bottle_price,
|
||||||
dropCount: oil.drop_count,
|
dropCount: oil.drop_count,
|
||||||
retailPrice: oil.retail_price ?? null,
|
retailPrice: oil.retail_price ?? null,
|
||||||
isActive: oil.is_active ?? true,
|
isActive: oil.is_active ?? true,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
oils.value = newOils
|
oils.value = newOils
|
||||||
oilsMeta.value = newMeta
|
oilsMeta.value = newMeta
|
||||||
@@ -86,8 +86,8 @@ export const useOilsStore = defineStore('oils', () => {
|
|||||||
|
|
||||||
async function deleteOil(name) {
|
async function deleteOil(name) {
|
||||||
await api.delete(`/api/oils/${encodeURIComponent(name)}`)
|
await api.delete(`/api/oils/${encodeURIComponent(name)}`)
|
||||||
oils.value.delete(name)
|
delete oils.value[name]
|
||||||
oilsMeta.value.delete(name)
|
delete oilsMeta.value[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const useRecipesStore = defineStore('recipes', () => {
|
|||||||
note: r.note ?? '',
|
note: r.note ?? '',
|
||||||
tags: r.tags ?? [],
|
tags: r.tags ?? [],
|
||||||
ingredients: (r.ingredients ?? []).map((ing) => ({
|
ingredients: (r.ingredients ?? []).map((ing) => ({
|
||||||
oil: ing.oil ?? ing.name,
|
oil: ing.oil_name ?? ing.oil ?? ing.name,
|
||||||
drops: ing.drops,
|
drops: ing.drops,
|
||||||
})),
|
})),
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ const recipesWithOil = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function getMeta(name) {
|
function getMeta(name) {
|
||||||
return oils.oilsMeta.get(name)
|
return oils.oilsMeta[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDropsForOil(recipe, oilName) {
|
function getDropsForOil(recipe, oilName) {
|
||||||
@@ -280,7 +280,7 @@ async function addOil() {
|
|||||||
|
|
||||||
function editOil(name) {
|
function editOil(name) {
|
||||||
editingOilName.value = name
|
editingOilName.value = name
|
||||||
const meta = oils.oilsMeta.get(name)
|
const meta = oils.oilsMeta[name]
|
||||||
editBottlePrice.value = meta?.bottlePrice || 0
|
editBottlePrice.value = meta?.bottlePrice || 0
|
||||||
editDropCount.value = meta?.dropCount || 0
|
editDropCount.value = meta?.dropCount || 0
|
||||||
editRetailPrice.value = meta?.retailPrice || null
|
editRetailPrice.value = meta?.retailPrice || null
|
||||||
|
|||||||
56
scripts/setup-runner.sh
Normal file
56
scripts/setup-runner.sh
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Setup Gitea Act Runner on this machine (host mode)
|
||||||
|
# Usage: bash scripts/setup-runner.sh <registration-token>
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TOKEN="${1:?Usage: $0 <registration-token>}"
|
||||||
|
INSTANCE="https://git.euphon.cloud"
|
||||||
|
RUNNER_NAME="hera-runner"
|
||||||
|
RUNNER_BIN="$HOME/bin/act_runner"
|
||||||
|
VERSION="v0.2.11"
|
||||||
|
|
||||||
|
echo "=== Installing act_runner ${VERSION} ==="
|
||||||
|
mkdir -p "$HOME/bin"
|
||||||
|
curl -L "https://gitea.com/gitea/act_runner/releases/download/${VERSION}/act_runner-${VERSION}-linux-amd64" \
|
||||||
|
-o "$RUNNER_BIN"
|
||||||
|
chmod +x "$RUNNER_BIN"
|
||||||
|
echo "Installed: $($RUNNER_BIN --version)"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Registering runner ==="
|
||||||
|
cd "$HOME"
|
||||||
|
$RUNNER_BIN register --no-interactive \
|
||||||
|
--instance "$INSTANCE" \
|
||||||
|
--token "$TOKEN" \
|
||||||
|
--name "$RUNNER_NAME" \
|
||||||
|
--labels "ubuntu-latest:host"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Setting up systemd user service ==="
|
||||||
|
mkdir -p "$HOME/.config/systemd/user"
|
||||||
|
cat > "$HOME/.config/systemd/user/act-runner.service" << EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Gitea Act Runner
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=%h
|
||||||
|
ExecStart=%h/bin/act_runner daemon
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=10
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
systemctl --user daemon-reload
|
||||||
|
systemctl --user enable act-runner
|
||||||
|
systemctl --user start act-runner
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== Done! ==="
|
||||||
|
systemctl --user status act-runner --no-pager | head -8
|
||||||
|
echo ""
|
||||||
|
echo "Check Gitea → Settings → Actions → Runners to verify."
|
||||||
Reference in New Issue
Block a user