-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Build and Deploy | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches-ignore: | ||
- main | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- 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 17 | ||
uses: actions/setup-java@v4.2.1 | ||
with: | ||
java-version: '17' | ||
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} | ||
- 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' }} | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
steps: | ||
- name: Deploy to production | ||
uses: johnbeynon/render-deploy-action@v0.0.8 | ||
with: | ||
service-id: ${{ secrets.MY_RENDER_SERVICE_ID }} | ||
api-key: ${{ secrets.MY_RENDER_API_KEY }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Usa una imagen base de Java 17 de Corretto | ||
FROM amazoncorretto:17-alpine | ||
|
||
# Copia el archivo JAR de la aplicación al contenedor | ||
COPY target/ms-ocr-0.0.1-SNAPSHOT.jar /app/ms-ocr.jar | ||
|
||
# Establece el directorio de trabajo en /app | ||
WORKDIR /app | ||
|
||
# Ejecuta la aplicación al iniciar el contenedor | ||
CMD ["java", "-jar", "ms-ocr.jar"] |
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