Skip to content

Commit 5a554f9

Browse files
committed
feat(62035): add CI/CD for TS and NPM + fixes
1 parent 01ead6e commit 5a554f9

File tree

3 files changed

+125
-7
lines changed

3 files changed

+125
-7
lines changed

.github/workflows/ci-cd-java.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ on:
1212
jarArtifactPath:
1313
required: false
1414
type: string
15+
dockerUser:
16+
required: true
17+
type: string
18+
dockerPassword:
19+
required: true
20+
type: string
1521

1622
env:
1723
IMAGE_NAME_MIXED_CASE: "${{ github.repository }}"
@@ -88,9 +94,8 @@ jobs:
8894
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
8995
uses: docker/login-action@v3
9096
with:
91-
registry: hsldevcom
92-
username: ${{ github.actor }}
93-
password: ${{ secrets.GITHUB_TOKEN }}
97+
username: ${{ inputs.dockerUser }}
98+
password: ${{ inputs.dockerPassword }}
9499

95100
- name: Build & Push Docker image
96101
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'

.github/workflows/ci-cd-kotlin.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ on:
1212
jarArtifactPath:
1313
required: false
1414
type: string
15+
dockerUser:
16+
required: true
17+
type: string
18+
dockerPassword:
19+
required: true
20+
type: string
1521

1622
env:
1723
IMAGE_NAME_MIXED_CASE: "${{ github.repository }}"
@@ -79,13 +85,13 @@ jobs:
7985
labels: |
8086
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
8187
org.opencontainers.image.vendor=hsldevcom
82-
- name: Login to Github Container Registry
88+
89+
- name: Login to Docker Hub
8390
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
8491
uses: docker/login-action@v3
8592
with:
86-
registry: hsldevcom
87-
username: ${{ github.actor }}
88-
password: ${{ secrets.GITHUB_TOKEN }}
93+
username: ${{ inputs.dockerUser }}
94+
password: ${{ inputs.dockerPassword }}
8995

9096
- name: Build & Push Docker image
9197
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: ci-cd-typescript.yml
2+
on:
3+
workflow_call:
4+
inputs:
5+
dockerUser:
6+
required: true
7+
type: string
8+
dockerPassword:
9+
required: true
10+
type: string
11+
uploadJarArtifact:
12+
required: false
13+
type: boolean
14+
default: false
15+
jarArtifactName:
16+
required: false
17+
type: string
18+
jarArtifactPath:
19+
required: false
20+
type: string
21+
checkAndTestOutsideDocker:
22+
required: false
23+
type: boolean
24+
default: false
25+
26+
27+
env:
28+
IMAGE_NAME_MIXED_CASE: "${{ github.repository }}"
29+
TEST_STAGE: tester
30+
PRODUCTION_STAGE: production
31+
32+
jobs:
33+
build-check-test-push:
34+
name: Build, check, test, push
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
with:
40+
clean: 'true'
41+
fetch-depth: 2
42+
43+
- name: Install Node
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: "lts/*"
47+
cache: "npm"
48+
49+
- name: Install NPM dependencies
50+
run: npm ci
51+
52+
- name: Check and test outside Docker
53+
if: ${{ inputs.checkAndTestOutsideDocker }}
54+
run: npm run check-and-build
55+
56+
- name: Lowercase Docker Image Name
57+
run: |
58+
echo "IMAGE_NAME=${IMAGE_NAME_MIXED_CASE,,}" >> "${GITHUB_ENV}"
59+
60+
- name: Extract docker metadata
61+
id: meta
62+
uses: docker/metadata-action@v5
63+
with:
64+
images: ${{ env.IMAGE_NAME }}
65+
tags: |
66+
type=edge,branch=main
67+
type=semver,pattern={{version}}
68+
type=semver,pattern={{major}}.{{minor}}
69+
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
70+
type=sha,format=long
71+
72+
- name: Setup Docker Buildx
73+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
74+
uses: docker/setup-buildx-action@v3
75+
76+
- name: Build and export to Docker
77+
uses: docker/build-push-action@v6
78+
with:
79+
context: .
80+
load: true
81+
target: "${{ env.TEST_STAGE }}"
82+
tags: "${{ env.IMAGE_NAME }}:${{ env.TEST_STAGE }}"
83+
84+
- name: Check and test
85+
run: |
86+
docker run --rm "${{ env.IMAGE_NAME }}:${{ env.TEST_STAGE }}"
87+
88+
- name: Login to Docker Hub
89+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/'))
90+
uses: docker/login-action@v3
91+
with:
92+
username: ${{ inputs.dockerUser }}
93+
password: ${{ inputs.dockerPassword }}
94+
95+
- name: Build and push
96+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/'))
97+
uses: docker/build-push-action@v6
98+
with:
99+
context: .
100+
push: true
101+
target: "${{ env.PRODUCTION_STAGE }}"
102+
tags: ${{ steps.meta.outputs.tags }}
103+
labels: ${{ steps.meta.outputs.labels }}
104+
105+
106+
107+

0 commit comments

Comments
 (0)