Install Quarkus using SDKMAN! in GitHub Actions workflow #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |