Skip to content

Commit 67bdcae

Browse files
committed
ci 🦊: Inventory Service
1 parent d09ef79 commit 67bdcae

1 file changed

Lines changed: 51 additions & 14 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Node.js CI
32

43
on:
@@ -7,29 +6,68 @@ on:
76
tags: ['v*']
87

98
jobs:
10-
build:
9+
# build:
10+
# runs-on: ubuntu-latest
11+
# defaults:
12+
# run:
13+
# working-directory: 1-order-service
14+
15+
# steps:
16+
# - uses: actions/checkout@v4
17+
# - name: Use Node.js
18+
# uses: actions/setup-node@v4
19+
# with:
20+
# node-version: '24.x'
21+
# - run: npm ci
22+
# - run: npm run build --if-present
23+
# - run: cat Dockerfile
24+
25+
order-service-build-and-push:
26+
# needs: build
1127
runs-on: ubuntu-latest
28+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/ci' || startsWith(github.ref, 'refs/tags/')
1229
defaults:
1330
run:
1431
working-directory: 1-order-service
1532

1633
steps:
1734
- uses: actions/checkout@v4
18-
- name: Use Node.js
19-
uses: actions/setup-node@v4
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Login to Docker Hub
40+
uses: docker/login-action@v3
2041
with:
21-
node-version: '24.x'
22-
- run: npm ci
23-
- run: npm run build --if-present
24-
- run: cat Dockerfile
42+
username: ${{ secrets.DOCKER_USERNAME }}
43+
password: ${{ secrets.DOCKER_PASSWORD }}
2544

26-
build-and-push:
27-
needs: build
45+
- name: Set environment variables
46+
run: |
47+
echo "IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/${{ vars.IMAGE_NAME_1 }}" >> $GITHUB_ENV
48+
echo "IMAGE_TAG=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
49+
if [[ $GITHUB_REF == refs/tags/* ]]; then
50+
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
51+
fi
52+
53+
- name: Build and Push Docker Image
54+
uses: docker/build-push-action@v5
55+
with:
56+
context: ./1-order-service
57+
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/ci' || startsWith(github.ref, 'refs/tags/') }}
58+
tags: |
59+
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
60+
platforms: linux/amd64
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max
63+
64+
inventory-service-build-and-push:
65+
# needs: build
2866
runs-on: ubuntu-latest
2967
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/ci' || startsWith(github.ref, 'refs/tags/')
3068
defaults:
3169
run:
32-
working-directory: 1-order-service
70+
working-directory: 2-inventory-service
3371

3472
steps:
3573
- uses: actions/checkout@v4
@@ -45,7 +83,7 @@ jobs:
4583

4684
- name: Set environment variables
4785
run: |
48-
echo "IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/${{ vars.IMAGE_NAME_1 }}" >> $GITHUB_ENV
86+
echo "IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/${{ vars.IMAGE_NAME_2 }}" >> $GITHUB_ENV
4987
echo "IMAGE_TAG=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
5088
if [[ $GITHUB_REF == refs/tags/* ]]; then
5189
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
@@ -54,11 +92,10 @@ jobs:
5492
- name: Build and Push Docker Image
5593
uses: docker/build-push-action@v5
5694
with:
57-
context: ./1-order-service
95+
context: ./2-inventory-service
5896
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/ci' || startsWith(github.ref, 'refs/tags/') }}
5997
tags: |
6098
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
6199
platforms: linux/amd64
62100
cache-from: type=gha
63101
cache-to: type=gha,mode=max
64-

0 commit comments

Comments
 (0)