-
Notifications
You must be signed in to change notification settings - Fork 190
117 lines (99 loc) · 3.59 KB
/
Copy pathweb-self-hosted.yml
File metadata and controls
117 lines (99 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Self-Hosted Web
on:
pull_request:
paths:
- "apps/web/**"
- "packages/db/**"
- "packages/core/**"
- "packages/shared/**"
- "pnpm-lock.yaml"
- ".github/workflows/web-self-hosted.yml"
- ".github/workflows/quality.yml"
push:
tags:
- "v*"
workflow_dispatch:
jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: 9.15.0
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
- name: Setup pnpm cache
uses: actions/cache@v5
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Verify self-hosted web
env:
JWT_SECRET: test-secret-for-web-ci-verify-1234567890
run: node --experimental-strip-types scripts/verify-release.mts --profile release --surface web-self-hosted --exclude-layer governance --exclude-layer e2e
- name: Validate Docker Compose
working-directory: apps/web
run: |
cp .env.example .env
docker compose config > /tmp/prompthub-web-compose.yaml
docker compose -f docker-compose.yml -f docker-compose.ghcr.yml config > /tmp/prompthub-web-compose-ghcr.yaml
docker:
runs-on: ubuntu-latest
needs: verify
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/prompthub-web
tags: |
type=semver,pattern={{version}}
type=semver,pattern=v{{version}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '-') }}
type=ref,event=tag
type=sha
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build self-hosted web image
uses: docker/build-push-action@v6
with:
context: .
file: apps/web/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Export Docker image archive
if: startsWith(github.ref, 'refs/tags/')
run: docker pull ghcr.io/${{ github.repository_owner }}/prompthub-web:${{ github.ref_name }} && docker save ghcr.io/${{ github.repository_owner }}/prompthub-web:${{ github.ref_name }} | gzip > prompthub-web-${{ github.ref_name }}.tar.gz
- name: Upload Docker image archive
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v6
with:
name: prompthub-web-image-${{ github.ref_name }}
path: prompthub-web-${{ github.ref_name }}.tar.gz