add builad and deploy gitea pipeline
This commit is contained in:
parent
1991fb5726
commit
af0c1bdaa6
93
.gitea/workflows/main.yml
Normal file
93
.gitea/workflows/main.yml
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
name: Gitea Action Maven build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['master']
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout the repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Maven
|
||||||
|
uses: stCarolas/setup-maven@v5
|
||||||
|
with:
|
||||||
|
maven-version: 3.9.9
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 21
|
||||||
|
distribution: 'oracle'
|
||||||
|
cache: 'maven'
|
||||||
|
|
||||||
|
- name: Build, Test and Package with Maven
|
||||||
|
run: mvn -B verify --file pom.xml -e
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: searchengine-artifact
|
||||||
|
path: |
|
||||||
|
target/*.jar
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
|
||||||
|
- name: Create Maven settings.xml
|
||||||
|
run: |
|
||||||
|
cat <<EOF > ~/.m2/settings.xml
|
||||||
|
<settings>
|
||||||
|
<servers>
|
||||||
|
<server>
|
||||||
|
<id>gitea</id>
|
||||||
|
<username>${{ vars.OWNER }}</username>
|
||||||
|
<password>${{ secrets.ACCESS_TOKEN }}</password>
|
||||||
|
</server>
|
||||||
|
</servers>
|
||||||
|
</settings>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Replace {owner} in pom.xml
|
||||||
|
run: sed -i "s/{owner}/${{ vars.OWNER }}/g" pom.xml
|
||||||
|
|
||||||
|
- name: Deploy to Gitea Packages
|
||||||
|
run: mvn deploy
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- name: Download artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: searchengine-artifact
|
||||||
|
path: artifact
|
||||||
|
|
||||||
|
- name: Install SSH Key
|
||||||
|
uses: shimataro/ssh-key-action@v2
|
||||||
|
with:
|
||||||
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
known_hosts: ${{ secrets.KNOWN_HOSTS }}
|
||||||
|
- name: Create Directory on Local Server
|
||||||
|
run: ssh -T ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} mkdir -p ${{ vars.DEPLOY_PATH }}
|
||||||
|
|
||||||
|
- name: Deploy to Local Server
|
||||||
|
run: scp -r artifact/* ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }}:${{ vars.DEPLOY_PATH }}
|
||||||
|
|
||||||
|
- name: Create .env file on Local Server
|
||||||
|
run: |
|
||||||
|
ssh -T ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} << EOF
|
||||||
|
echo "DB_USER=${{ vars.DB_USER }}" > ${{ vars.DEPLOY_PATH }}/.env
|
||||||
|
echo "DB_PASSWORD=${{ vars.DB_PASSWORD }}" >> ${{ vars.DEPLOY_PATH }}/.env
|
||||||
|
echo "DB_URL=${{ vars.DB_URL }}" >> ${{ vars.DEPLOY_PATH }}/.env
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build and Run Docker Image with Docker Compose
|
||||||
|
run: |
|
||||||
|
ssh -T ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} << EOF
|
||||||
|
cd ${{ vars.DEPLOY_PATH }}
|
||||||
|
docker compose down
|
||||||
|
docker compose up -d --build
|
||||||
|
EOF
|
6
Dockerfile
Normal file
6
Dockerfile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
FROM openjdk:21-jdk-slim
|
||||||
|
WORKDIR /app
|
||||||
|
COPY target/searchengine-*.jar ./searchengine.jar
|
||||||
|
COPY .env ./
|
||||||
|
EXPOSE 8080
|
||||||
|
CMD ["java", "-jar", "searchengine.jar"]
|
10
docker-compose.yml
Normal file
10
docker-compose.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
image: searchengine
|
||||||
|
container_name: searchengine
|
||||||
|
ports:
|
||||||
|
- "8090:8080"
|
||||||
|
restart: always
|
33
pom.xml
33
pom.xml
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
<groupId>dev.kuksa</groupId>
|
<groupId>dev.kuksa</groupId>
|
||||||
<artifactId>searchengine</artifactId>
|
<artifactId>searchengine</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>23</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
<maven.compiler.target>23</maven.compiler.target>
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -51,4 +51,31 @@
|
|||||||
<version>4.0.0</version>
|
<version>4.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>gitea</id>
|
||||||
|
<url>https://git.kuksa.dev/api/packages/{owner}/maven</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>gitea</id>
|
||||||
|
<url>https://git.kuksa.dev/api/packages/{owner}/maven</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>gitea</id>
|
||||||
|
<url>https://git.kuksa.dev/api/packages/{owner}/maven</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
</project>
|
</project>
|
Loading…
x
Reference in New Issue
Block a user