Merge pull request #54 from BableshAAzad/dev #14
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: | |
- master | |
pull_request: | |
branches: | |
- master | |
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: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Cache Maven dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven | |
- name: Build with Maven | |
run: mvn clean install | |
- name: Run tests | |
run: mvn test | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install lftp | |
run: sudo apt-get update && sudo apt-get install -y lftp | |
- name: Deploy to cPanel | |
env: | |
FTP_SERVER: ${{ secrets.FTP_SERVER }} | |
FTP_USERNAME: ${{ secrets.FTP_USERNAME }} | |
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} | |
DB_HOST_NAME: ${{ secrets.DB_HOST_NAME }} | |
DB_PORT: ${{ secrets.DB_PORT }} | |
DB_NAME: ${{ secrets.DB_NAME }} | |
DB_USERNAME: ${{ secrets.DB_USERNAME }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
run: | | |
echo "Deploying application to cPanel..." | |
# Use lftp to mirror the build artifacts to the public_html directory | |
lftp -u $FTP_USERNAME,$FTP_PASSWORD $FTP_SERVER <<EOF | |
set ssl:verify-certificate no | |