Skip to content

Commit 3bf1f3d

Browse files
committed
a
1 parent 3bf6a59 commit 3bf1f3d

File tree

1 file changed

+3
-211
lines changed

1 file changed

+3
-211
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 211 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
name: CI/CD Workflow
22

3-
# env:
4-
# VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
5-
# VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
6-
7-
83
on:
94
push:
105
branches:
@@ -39,9 +34,6 @@ jobs:
3934
needs: extract-versions
4035
name: Detect Affected Apps
4136
runs-on: ubuntu-latest
42-
# env:
43-
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
44-
# TURBO_TEAM: ${{ vars.TURBO_TEAM }}
4537
outputs:
4638
is_backend_changed: ${{ steps.ex5.outputs.is_backend_changed }}
4739
is_frontend_changed: ${{ steps.ex5.outputs.is_frontend_changed }}
@@ -80,69 +72,25 @@ jobs:
8072
- name: Prune unnecessary packages
8173
run: pnpm prune
8274

83-
# lint,formatチェック(turboのキャッシュを使う)
84-
# - name: Lint and Format changes
85-
# run: pnpm turbo run check
86-
# # run: turbo run check --filter=...[HEAD^]
87-
88-
# type checkを実行(turboのキャッシュを使う)
89-
# - name: Type check
90-
# run: pnpm turbo run type-check
91-
# run: turbo run type-check --filter=...[HEAD^]
92-
93-
# type checkを実行(turboのキャッシュを使う)
94-
# - name: Test
95-
# run: pnpm turbo run test
96-
9775
# buildが必要なappを特定(turboのキャッシュを使う)
9876
- name: Run Turbo dry-run
9977
id: ex5
10078
run: |
10179
pnpm turbo run build --dry-run=json > turbo-dry-run.json
102-
BACKEND_CACHE_STATUS=$(cat turbo-dry-run.json | jq '.tasks[] | select(.package == "backend")' | jq -r '.cache.status')
10380
FRONTEND_CACHE_STATUS=$(cat turbo-dry-run.json | jq '.tasks[] | select(.package == "frontend")' | jq -r '.cache.status')
104-
if [ $BACKEND_CACHE_STATUS = "HIT" ]; then
105-
echo "is_backend_changed=false" >> $GITHUB_OUTPUT
106-
else
107-
echo "is_backend_changed=true" >> $GITHUB_OUTPUT
108-
fi
10981
if [ $FRONTEND_CACHE_STATUS = "HIT" ]; then
11082
echo "is_frontend_changed=false" >> $GITHUB_OUTPUT
11183
else
11284
echo "is_frontend_changed=true" >> $GITHUB_OUTPUT
11385
fi
114-
echo $BACKEND_CACHE_STATUS
11586
echo $FRONTEND_CACHE_STATUS
116-
cat turbo-dry-run.json
117-
118-
# - name: Set Backend Output
119-
# id: set_backend_output
120-
# run: echo "is_backend_changed=${{ env.is_backend_changed }}" >> $GITHUB_OUTPUT
121-
122-
# - name: Set Frontend Output
123-
# id: set_frontend_output
124-
# run: echo "is_frontend_changed=${{ env.is_frontend_changed }}" >> $GITHUB_OUTPUT
125-
126-
127-
# test-buil:
128-
# name: Test and Build Next.js App
129-
# runs-on: ubuntu-latest
130-
# needs: turbo
131-
# steps:
132-
# - name: Debug Outputs
133-
# run: |
134-
# echo "is_backend_changed: ${{ needs.turbo.outputs.is_backend_changed }}"
135-
# echo "is_frontend_changed: ${{ needs.turbo.outputs.is_frontend_changed }}"
13687
13788
13889
# 2. Next.jsのテストとビルド
139-
test-build-next:
90+
build-next:
14091
if: ${{ needs.turbo.outputs.is_frontend_changed == 'true' }}
14192
name: Test and Build Next.js App
14293
runs-on: ubuntu-latest
143-
# env:
144-
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
145-
# TURBO_TEAM: ${{ vars.TURBO_TEAM }}
14694
needs: [extract-versions, turbo]
14795
steps:
14896
- name: env
@@ -176,140 +124,19 @@ jobs:
176124
- name: Prune unnecessary packages
177125
run: node -v
178126

179-
# - name: Prune unnecessary packages
180-
# run: pnpm prune
181-
182-
# - name: Run tests
183-
# run: pnpm turbo run test --filter=frontend
184-
# - name: Install Vercel CLI
185-
# run: pnpm install -g vercel@latest
186-
187127
- name: Pull Vercel Environment Information
188128
working-directory: apps/frontend
189129
run: pnpm vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
190-
# run: pnpm dlx vercel pull --yes --environment=production
191-
192-
# - name: Build Project Artifacts
193-
# run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
194130

195131
- name: Build
196132
run: pnpm turbo run vercel-gha-build --filter=frontend
197133

198134

199-
200-
# 3. Expressのテストとビルド
201-
test-build-express:
202-
if: ${{ needs.turbo.outputs.is_backend_changed == 'true' }}
203-
name: Test and Build Express App
204-
runs-on: ubuntu-latest
205-
# env:
206-
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
207-
# TURBO_TEAM: ${{ vars.TURBO_TEAM }}
208-
needs: [extract-versions, turbo]
209-
steps:
210-
- name: env
211-
run: echo ${{ needs.turbo.outputs.is_backend_changed }}
212-
213-
- name: Checkout code
214-
uses: actions/checkout@v3
215-
216-
- name: Set up pnpm
217-
uses: pnpm/action-setup@v4
218-
with:
219-
version: ${{ needs.extract-versions.outputs.pnpm_version }}
220-
221-
- name: Set up Node.js
222-
uses: actions/setup-node@v4
223-
with:
224-
node-version: ${{ needs.extract-versions.outputs.node_version }}
225-
cache: pnpm
226-
227-
- name: Cache turbo build setup
228-
uses: actions/cache@v4
229-
with:
230-
path: .turbo
231-
key: ${{ runner.os }}-turbo-${{ github.sha }}
232-
restore-keys: |
233-
${{ runner.os }}-turbo-
234-
235-
- name: Install dependencies
236-
run: pnpm install --frozen-lockfile
237-
238-
- name: Prune unnecessary packages
239-
run: pnpm prune
240-
241-
# # - name: Run tests
242-
# # run: pnpm turbo run test --filter=backend
243-
244-
- name: Build Express app
245-
run: pnpm turbo build --filter=backend
246-
247-
# - name: Prune app
248-
# run: pnpm turbo prune backend --docker
249-
250-
# - name: Set up Docker Buildx
251-
# uses: docker/setup-buildx-action@v3
252-
253-
# - name: Restore Docker Cache
254-
# uses: actions/cache@v3
255-
# with:
256-
# path: /tmp/.buildx-cache
257-
# key: ${{ runner.os }}-docker-${{ github.sha }}
258-
# restore-keys: |
259-
# ${{ runner.os }}-docker-
260-
261-
# - name: Build Docker Image
262-
# run: |
263-
# docker buildx build \
264-
# --tag senuweb/apps:backend-latest \
265-
# --file ./out/full/apps/backend/DockerFile \
266-
# --cache-from type=local,src=/tmp/.buildx-cache \
267-
# --cache-to type=local,dest=/tmp/.buildx-cache,mode=max \
268-
# --load \
269-
# ./out
270-
271-
# - name: Check images
272-
# run: docker images
273-
274-
# 脆弱性チェック
275-
# - name: Scan image with Trivy
276-
# uses: aquasecurity/trivy-action@master
277-
# with:
278-
# image-ref: senuweb/apps:backend-latest
279-
# format: "table"
280-
# severity: "CRITICAL,HIGH"
281-
# # exit-code: 1
282-
# env:
283-
# DOCKER_HOST: unix:///var/run/docker.sock
284-
285-
# - name: Check Docker best practices with Dockle
286-
# uses: erzz/dockle-action@v1
287-
# with:
288-
# image: senuweb/apps:backend-latest
289-
# failure-threshold: fatal
290-
# # exit-code: 1
291-
# env:
292-
# DOCKER_HOST: unix:///var/run/docker.sock
293-
294-
# - name: Log in to Docker Hub
295-
# if: github.event_name == 'push'
296-
# uses: docker/login-action@v2
297-
# with:
298-
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
299-
# password: ${{ secrets.DOCKER_PASSWORD }}
300-
301-
# - name: Push Docker Image
302-
# if: github.event_name == 'push'
303-
# run: docker push senuweb/apps:backend-latest
304-
305135
# 4. Next.jsのデプロイ (Vercel)
306136
deploy-next:
307137
if: github.event_name == 'push'
308138
name: Deploy Next.js App to Vercel
309139
runs-on: ubuntu-latest
310-
# env:
311-
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
312-
# TURBO_TEAM: ${{ vars.TURBO_TEAM }}
313140
needs: [extract-versions, test-build-next]
314141
steps:
315142
- name: Checkout code
@@ -337,53 +164,18 @@ jobs:
337164
- name: Install dependencies
338165
run: pnpm install --frozen-lockfile
339166

340-
# - name: Install Vercel CLI
341-
# run: pnpm install -g vercel@latest
342-
343167
- name: Pull Vercel Environment Information
344168
run: pnpm vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
345-
# run: pnpm dlx vercel pull --yes --environment=production
346169

347170
- name: Build
348171
run: pnpm turbo run vercel-gha-build --filter=frontend
349172

350-
# - name: Build Project Artifacts
351-
# run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
352-
353-
# - name: Ls
354-
# run: ls -al apps/frontend/.vercel
355-
356-
# - name: Ls
357-
# run: ls -al apps/frontend/.next
358-
359173
- name: Cp n
360174
run: cp -a apps/frontend/.next/. .next/
361175

362176
- name: Cp v
363177
run: cp -a apps/frontend/.vercel/. .vercel/
364178

365-
# - name: Ls
366-
# run: ls -al
367-
368-
# - name: Ls
369-
# run: ls -al .vercel
370-
371-
# - name: Ls
372-
# run: ls -al .next
373-
374179
- name: Deploy Project Artifacts to Vercel
375-
#working-directory: apps/frontend
376-
run: pnpm vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
377-
# run: pnpm dlx vercel deploy --prebuilt --prod
378-
# run: pnpm dlx vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }}
379-
380-
381-
# 5. Expressのデプロイ (EC2)
382-
# deploy-express:
383-
# if: github.event_name == 'push'
384-
# name: Deploy Express App to EC2
385-
# runs-on: ubuntu-latest
386-
# needs: [test-build-express]
387-
# steps:
388-
# - name: Deploy
389-
# run: curl ${{ secrets.DEPLOY_HOOK }}
180+
working-directory: apps/frontend
181+
run: pnpm vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

0 commit comments

Comments
 (0)