Skip to content

Commit

Permalink
Update build-and-deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveraluiss11 authored May 2, 2024
1 parent 6cafdfd commit b19bfb5
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: Build and Deploy
name: Build and Deploy to Production

on:
pull_request:
branches:
- main
push:
branches:
- develop

jobs:
build:
Expand All @@ -15,42 +12,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Determine Spring profile
id: set_profile
run: |
if [ "${{ github.ref }}" = 'refs/heads/main' ]; then
echo "prod"
elif [ "${{ github.ref }}" = 'refs/heads/develop' ]; then
echo "dev"
else
echo "default"
fi
- name: Set up JDK 21
uses: actions/setup-java@v4.2.1
with:
java-version: '21'
distribution: 'corretto'

- name: Build with Maven
run: |
export SPRING_PROFILES_ACTIVE=$(/bin/bash -c 'echo "${{ steps.set_profile.outputs.profile }}"')
mvn clean package -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}
run: mvn clean package

- name: Log in to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: |
docker build -t ms-ocr .
docker tag ms-ocr ${{ secrets.DOCKER_USERNAME }}/ms-ocr:${{ github.ref == 'refs/heads/main' && 'prod' || github.ref == 'refs/heads/develop' && 'dev' }}
docker push ${{ secrets.DOCKER_USERNAME }}/ms-ocr:${{ github.ref == 'refs/heads/main' && 'prod' || github.ref == 'refs/heads/develop' && 'dev' }}
docker tag ms-ocr ${{ secrets.DOCKER_USERNAME }}/ms-ocr:production
docker push ${{ secrets.DOCKER_USERNAME }}/ms-ocr:production
deploy:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Deploy to production
- name: Deploy to Production
uses: johnbeynon/render-deploy-action@v0.0.8
with:
service-id: ${{ secrets.MY_RENDER_SERVICE_ID }}
Expand Down

0 comments on commit b19bfb5

Please sign in to comment.