Update application.properties #4
This file contains hidden or 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: Build and Deploy | |
on: | |
push: | |
branches: | |
- dev | |
pull_request: | |
branches: | |
- dev | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '21' | |
- name: Update application.properties | |
run: | | |
sed -i 's|spring.datasource.url=.*|spring.datasource.url=${{ secrets.SPRING_DATASOURCE_URL }}|' src/main/resources/application.properties | |
- name: Build with Maven | |
run: mvn clean install | |
- name: Build Docker image | |
run: docker build -t spring-jwt-auth . | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push Docker image | |
run: | | |
docker tag spring-jwt-auth ${{ secrets.DOCKER_USERNAME }}/spring-jwt-auth:latest | |
docker push ${{ secrets.DOCKER_USERNAME }}/spring-jwt-auth:latest | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Pull and run Docker image | |
run: | | |
docker pull ${{ secrets.DOCKER_USERNAME }}/spring-jwt-auth:latest | |
docker run -d -p 8080:8080 --name spring-jwt-auth-container ${{ secrets.DOCKER_USERNAME }}/spring-jwt-auth:latest |