Skip to content

Commit 63a87a1

Browse files
committed
chore: restructure GitHub Actions workflows
1 parent 99c3c82 commit 63a87a1

7 files changed

Lines changed: 65 additions & 103 deletions

File tree

.github/workflows/backend-build-image.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/backend-lint.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/frontend-build-image.yml renamed to .github/workflows/build.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Frontend Build Image
1+
name: Build Images
22

33
on:
44
workflow_call:
55

66
jobs:
7-
frontend-build-image:
7+
frontend:
88
runs-on: ubuntu-latest
99

1010
steps:
@@ -35,3 +35,33 @@ jobs:
3535
VITE_API_BASE_URL=${{ secrets.FRONTEND_API_BASE_URL }}
3636
cache-from: type=registry,ref=ghcr.io/nctucsunion/pastexam:frontend-buildcache
3737
cache-to: type=registry,ref=ghcr.io/nctucsunion/pastexam:frontend-buildcache,mode=max
38+
39+
backend:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v2
48+
49+
- name: Login to GitHub Container Registry
50+
uses: docker/login-action@v2
51+
with:
52+
registry: ghcr.io
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Build and push Backend Docker image
57+
uses: docker/build-push-action@v4
58+
with:
59+
context: ./backend
60+
file: ./backend/Dockerfile
61+
push: true
62+
platforms: linux/amd64
63+
tags: |
64+
ghcr.io/nctucsunion/pastexam:backend
65+
ghcr.io/nctucsunion/pastexam:backend-${{ github.sha }}
66+
cache-from: type=registry,ref=ghcr.io/nctucsunion/pastexam:backend-buildcache
67+
cache-to: type=registry,ref=ghcr.io/nctucsunion/pastexam:backend-buildcache,mode=max

.github/workflows/frontend-test.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Frontend Lint
1+
name: Lint
22

33
on:
44
workflow_call:
55

66
jobs:
7-
frontend-lint:
7+
frontend:
88
runs-on: ubuntu-latest
99

1010
steps:
@@ -41,3 +41,13 @@ jobs:
4141
- name: Run lint
4242
run: pnpm run lint
4343
working-directory: ./frontend
44+
45+
backend:
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Backend lint placeholder
53+
run: echo "Backend lint (flake8) will be added soon."

.github/workflows/main.yml

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,21 @@ permissions:
99
packages: write
1010

1111
jobs:
12-
frontend-lint:
13-
uses: ./.github/workflows/frontend-lint.yml
12+
lint:
13+
uses: ./.github/workflows/lint.yml
1414

15-
backend-lint:
16-
uses: ./.github/workflows/backend-lint.yml
15+
test:
16+
needs: lint
17+
uses: ./.github/workflows/test.yml
1718

18-
frontend-test:
19-
needs:
20-
- frontend-lint
21-
- backend-lint
22-
uses: ./.github/workflows/frontend-test.yml
23-
24-
backend-test:
25-
needs:
26-
- frontend-lint
27-
- backend-lint
28-
uses: ./.github/workflows/backend-test.yml
29-
30-
frontend-build-image:
31-
needs:
32-
- frontend-test
33-
- backend-test
34-
if: github.ref == 'refs/heads/main'
35-
uses: ./.github/workflows/frontend-build-image.yml
36-
secrets: inherit
37-
38-
backend-build-image:
39-
needs:
40-
- frontend-test
41-
- backend-test
19+
build:
20+
needs: test
4221
if: github.ref == 'refs/heads/main'
43-
uses: ./.github/workflows/backend-build-image.yml
22+
uses: ./.github/workflows/build.yml
4423
secrets: inherit
4524

4625
deploy:
47-
needs:
48-
- frontend-build-image
49-
- backend-build-image
26+
needs: build
5027
if: github.ref == 'refs/heads/main'
5128
uses: ./.github/workflows/deploy.yml
5229
secrets: inherit
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
name: Backend Test
1+
name: Test
22

33
on:
44
workflow_call:
55

66
jobs:
7-
backend-test:
7+
frontend:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Placeholder frontend tests
15+
run: echo "Frontend tests are not configured yet."
16+
17+
backend:
818
runs-on: ubuntu-latest
919

1020
steps:

0 commit comments

Comments
 (0)