Skip to content

Commit e252d0e

Browse files
committed
reuse workflow
1 parent a31dd67 commit e252d0e

File tree

3 files changed

+58
-85
lines changed

3 files changed

+58
-85
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build and Deploy
2+
on:
3+
workflow_call:
4+
inputs:
5+
branch:
6+
required: true
7+
type: string
8+
tag:
9+
required: true
10+
type: string
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v5
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 24
20+
cache: npm
21+
- run: npm ci
22+
23+
deploy:
24+
needs: build
25+
runs-on: ubuntu-latest
26+
if: ${{ github.event_name == 'push' }}
27+
steps:
28+
- uses: actions/checkout@v5
29+
- uses: docker/setup-buildx-action@v3
30+
- name: Log in to GitHub Container Registry
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Build and push
37+
uses: docker/build-push-action@v6
38+
with:
39+
context: .
40+
push: true
41+
file: Dockerfile.production
42+
cache-from: ghcr.io/${{ github.repository }}:${{ inputs.tag }}
43+
cache-to: type=inline
44+
tags: ghcr.io/${{ github.repository }}:${{ inputs.tag }}

.github/workflows/main.yml

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,13 @@ name: Main
22

33
on:
44
push:
5-
branches:
6-
- v2_bug_fixes
5+
branches: [ main ]
76
pull_request:
8-
branches:
9-
- v2_bug_fixes
7+
branches: [ main ]
108

119
jobs:
12-
build:
13-
runs-on: ubuntu-latest
14-
15-
steps:
16-
- uses: actions/checkout@v5
17-
18-
- uses: actions/setup-node@v4
19-
with:
20-
node-version: 24
21-
cache: 'npm'
22-
- run: npm ci
23-
24-
deploy:
25-
needs: build
26-
runs-on: ubuntu-latest
27-
if: ${{ github.event_name == 'push' }}
28-
29-
steps:
30-
- uses: actions/checkout@v5
31-
32-
- uses: docker/setup-buildx-action@v3
33-
34-
- name: Log in to GitHub Container Registry
35-
uses: docker/login-action@v3
36-
with:
37-
registry: ghcr.io
38-
username: ${{ github.actor }}
39-
password: ${{ secrets.GITHUB_TOKEN }}
40-
41-
- name: Build and push
42-
uses: docker/build-push-action@v6
43-
with:
44-
context: .
45-
push: true
46-
file: Dockerfile.rpdouction
47-
cache-from: ghcr.io/${{ github.repository }}:v2
48-
cache-to: type=inline
49-
tags: ghcr.io/${{ github.repository }}:v2
10+
call:
11+
uses: ./.github/workflows/build-and-deploy.yml
12+
with:
13+
branch: main
14+
tag: latest

.github/workflows/v2.yml

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,13 @@
11
name: V2
2-
32
on:
43
push:
5-
branches:
6-
- v2_bug_fixes
4+
branches: [ v2_bug_fixes ]
75
pull_request:
8-
branches:
9-
- v2_bug_fixes
6+
branches: [ v2_bug_fixes ]
107

118
jobs:
12-
build:
13-
runs-on: ubuntu-latest
14-
15-
steps:
16-
- uses: actions/checkout@v5
17-
18-
- uses: actions/setup-node@v4
19-
with:
20-
node-version: 24
21-
cache: 'npm'
22-
- run: npm ci
23-
24-
deploy:
25-
needs: build
26-
runs-on: ubuntu-latest
27-
if: ${{ github.event_name == 'push' }}
28-
29-
steps:
30-
- uses: actions/checkout@v5
31-
32-
- uses: docker/setup-buildx-action@v3
33-
34-
- name: Log in to GitHub Container Registry
35-
uses: docker/login-action@v3
36-
with:
37-
registry: ghcr.io
38-
username: ${{ github.actor }}
39-
password: ${{ secrets.GITHUB_TOKEN }}
40-
41-
- name: Build and push
42-
uses: docker/build-push-action@v6
43-
with:
44-
context: .
45-
push: true
46-
file: Dockerfile.rpdouction
47-
cache-from: ghcr.io/${{ github.repository }}:v2
48-
cache-to: type=inline
49-
tags: ghcr.io/${{ github.repository }}:v2
9+
call:
10+
uses: ./.github/workflows/build-and-deploy.yml
11+
with:
12+
branch: v2_bug_fixes
13+
tag: v2

0 commit comments

Comments
 (0)