workflows add
Some checks failed
Java Application Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Java Application Build and Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -1,19 +1,39 @@
|
|||||||
name: Gitea Actions Demo
|
name: Java Application Build and Deploy
|
||||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main # Trigger on push to main branch
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Explore-Gitea-Actions:
|
build-and-deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: gitea-runner-label # Use the label matching your Gitea runner
|
||||||
steps:
|
steps:
|
||||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
- name: Checkout code
|
||||||
- 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
|
|
||||||
uses: actions/checkout@v4
|
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: Set up JDK 17
|
||||||
- name: List files in the repository
|
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: |
|
run: |
|
||||||
ls ${{ gitea.workspace }}
|
# Assuming Docker is installed and configured on runner or server
|
||||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
# 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
|
||||||
|
Reference in New Issue
Block a user