diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 394c807..15ee393 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,19 +1,39 @@ -name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 -on: [push] +name: Java Application Build and Deploy + +on: + push: + branches: + - main # Trigger on push to main branch jobs: - Explore-Gitea-Actions: - runs-on: ubuntu-latest + build-and-deploy: + runs-on: gitea-runner-label # Use the label matching your Gitea runner steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code + - name: Checkout code uses: actions/checkout@v4 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' # or choose your preferred distribution + cache: 'maven' + + - name: Set up Maven + uses: stCarolas/setup-maven@v5 + with: + maven-version: '3.9.9' + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Deploy to Docker run: | - ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file + # Assuming Docker is installed and configured on runner or server + # Build docker image + docker build -t my-java-app:latest . + # Stop previous container if running + docker stop my-java-app || true + docker rm my-java-app || true + # Run new container + docker run -d --name my-java-app -p 8080:8080 my-java-app:latest