-
Notifications
You must be signed in to change notification settings - Fork 5
71 lines (60 loc) · 1.79 KB
/
catalog-service-ci-cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: CI/CD Pipeline
on:
push:
branches:
- service-catalog
pull_request:
branches:
- service-catalog
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'
- name: Install SDKMAN!
run: |
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install quarkus
- name: Build with Quarkus
run: |
cd catalog/catalog-service/
quarkus build
- name: Run Tests
run: |
cd catalog/catalog-service/
quarkus test
- name: Set Docker Image Tag
id: docker_tag
run: echo "tag=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
- name: Build Docker image
run: |
cd catalog/catalog-service/
docker-compose up --build -d
- name: Push Docker image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push <dockerhub_username>/<image_name>:${{ env.tag }}
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to VM
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USERNAME }}
key: ${{ secrets.VM_SSH_KEY }}
script: |
docker pull <dockerhub_username>/<image_name>:${{ needs.build.outputs.tag }}
docker-compose down
docker-compose up -d