This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
Update README.md #50
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: Server | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
# - name: Inject Environments | |
# run: | | |
# sed -i 's#{DATABASE_URL}#${{ secrets.DATABASE_URL }}#' server/src/main/resources/application.yml | |
# sed -i 's#{DATABASE_USERNAME}#${{ secrets.DATABASE_USERNAME }}#' server/src/main/resources/application.yml | |
# sed -i 's#{DATABASE_PASSWORD}#${{ secrets.DATABASE_PASSWORD }}#' server/src/main/resources/application.yml | |
# sed -i 's#{JWT_SECRET_KEY}#${{ secrets.JWT_SECRET_KEY }}#' server/src/main/resources/application.yml | |
# sed -i 's#{AZURE_OPENAI_API_KEY}#${{ secrets.AZURE_OPENAI_API_KEY }}#' server/src/main/resources/application.yml | |
# sed -i 's#{AZURE_OPENAI_ENDPOINT}#${{ secrets.AZURE_OPENAI_ENDPOINT }}#' server/src/main/resources/application.yml | |
# sed -i 's#{NEWS_API_KEY}#${{ secrets.NEWS_API_KEY }}#' server/src/main/resources/application.yml | |
- name: Set yml | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: 'server/src/main/resources/application.yml' | |
env: | |
spring.datasource.url: ${{ secrets.DATABASE_URL }} | |
spring.datasource.username: ${{ secrets.DATABASE_USERNAME }} | |
spring.datasource.password: ${{ secrets.DATABASE_PASSWORD }} | |
jwt.secret-key: ${{ secrets.JWT_SECRET_KEY }} | |
spring.ai.azure.openai.api-key: ${{ secrets.AZURE_OPENAI_API_KEY }} | |
spring.ai.azure.openai.endpoint: ${{ secrets.AZURE_OPENAI_ENDPOINT }} | |
news.api-key: ${{ secrets.NEWS_API_KEY }} | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build with Gradle | |
run: | | |
cd server | |
./gradlew build | |
- name: Log in to Azure Container Registry | |
uses: azure/docker-login@v1 | |
with: | |
login-server: goodfarmserver.azurecr.io | |
username: ${{ secrets.ACR_USERNAME }} | |
password: ${{ secrets.ACR_PASSWORD }} | |
- name: Build and push Docker image | |
run: | | |
cd server | |
docker build --platform linux/amd64 -t goodfarmserver.azurecr.io/goodfarmserver:latest . | |
docker push goodfarmserver.azurecr.io/goodfarmserver:latest | |
- name: Azure Login | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Deploy to Azure Container Apps | |
run: az containerapp update --name goodfarm-server --resource-group rg-team-garlic --image goodfarmserver.azurecr.io/goodfarmserver:latest |