-
Notifications
You must be signed in to change notification settings - Fork 477
133 lines (113 loc) · 3.37 KB
/
Copy pathfrontend-ci-cd.yml
File metadata and controls
133 lines (113 loc) · 3.37 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Frontend CI/CD
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
paths:
- 'ui/**'
- '.github/workflows/frontend-ci-cd.yml'
pull_request:
branches:
- main
paths:
- 'ui/**'
- '.github/workflows/frontend-ci-cd.yml'
env:
REGISTRY: chaitin-registry.cn-hangzhou.cr.aliyuncs.com/monkeycode
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Get version
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=$(git describe --tags --always --dirty)
fi
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Install dependencies
run: |
cd ui
pnpm install
- name: Build frontend
run: |
cd ui
echo "VITE_APP_VERSION=${{ steps.get_version.outputs.VERSION }}" >> .env.production
pnpm run build
- name: 'Tar files'
run: tar -cvf ui/dist.tar ui/dist
- name: List files for debugging
run: |
echo "Current directory: $(pwd)"
echo "Listing current directory:"
ls -la
echo "Listing dist directory:"
ls -la ui/dist || echo "dist directory not found"
echo "Checking if dist.tar exists:"
ls -la ui/dist.tar || echo "dist.tar not found"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: frontend-build
path: ui/dist.tar
if-no-files-found: error
include-hidden-files: true
package:
needs: build
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: frontend-build
- name: Check file structure
run: |
echo "Current directory: $(pwd)"
echo "Listing current directory:"
ls -la
- name: Extract files
run: |
tar -xvf dist.tar
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Aliyun Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.CT_ALIYUN_USER }}
password: ${{ secrets.CT_ALIYUN_PASS }}
- name: Package and push
uses: docker/build-push-action@v5
with:
context: ui
file: ui/.Dockerfile
push: true
platforms: linux/amd64, linux/arm64
tags: |
${{ env.REGISTRY }}/frontend:v${{ needs.build.outputs.version }}
${{ env.REGISTRY }}/frontend:latest
cache-from: type=gha
cache-to: type=gha,mode=max