Skip to content

Commit 42b7f79

Browse files
committed
ci 🦊: Add docker for Order Service
1 parent da12ea9 commit 42b7f79

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

.github/workflows/node.js.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
tags: ['v*']
77

88
jobs:
9-
Order_Service_Build:
9+
build:
1010
runs-on: ubuntu-latest
1111
defaults:
1212
run:
@@ -21,3 +21,37 @@ jobs:
2121
- run: npm ci
2222
- run: npm run build --if-present
2323
- run: cat Dockerfile
24+
25+
build-and-push:
26+
needs: build
27+
runs-on: ubuntu-latest
28+
working-directory: 1-order-service
29+
if: github.ref == 'refs/heads/main' || 'refs/heads/ci' || startsWith(github.ref, 'refs/tags/')
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Login to Docker Hub
37+
uses: docker/login-action@v3
38+
with:
39+
username: ${{ secrets.DOCKER_USERNAME }}
40+
password: ${{ secrets.DOCKER_PASSWORD }}
41+
- name: Set environment variables
42+
run: |
43+
echo "IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/${{ vars.IMAGE_NAME_1 }}" >> $GITHUB_ENV
44+
echo "IMAGE_TAG=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
45+
if [[ $GITHUB_REF == refs/tags/* ]]; then
46+
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
47+
fi
48+
- name: Build and Push Docker Image
49+
uses: docker/build-push-action@v5
50+
with:
51+
context: .
52+
push: ${{ github.ref == 'refs/heads/main' ||'refs/heads/ci' || startsWith(github.ref, 'refs/tags/') }}
53+
tags: |
54+
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
55+
platforms: linux/amd64
56+
cache-from: type=gha
57+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)