-
Notifications
You must be signed in to change notification settings - Fork 7
64 lines (55 loc) · 1.86 KB
/
main.yml
File metadata and controls
64 lines (55 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: CI for RandomChat
# Trigger workflow on push/pull request to main branch and manually
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy'
required: true
default: 'main'
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout code
- name: Checkout repository
uses: actions/checkout@v3
with:
# Checkout the branch from input or default
ref: ${{ github.event.inputs.branch || github.ref }}
# Step 2: Set up Java (match your Spring Boot version)
- name: Set up Java 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
# Step 3: Cache Maven dependencies (optional, speeds up builds)
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Step 4: Build the Spring Boot project
- name: Build with Maven
run: mvn clean package -DskipTests
# Step 5: Run tests
- name: Run tests
run: mvn test
# Step 6: List the generated jar
- name: List target directory
run: ls -l target/
# Step 7 Trigger deployment via webhook
- name: Trigger deployment via webhook
env:
DEPLOY_HOOK_URL: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
run: |
echo "Triggering deployment..."
curl -X POST "$DEPLOY_HOOK_URL"
echo "Deployment triggered via webhook."
# Step 8: Wait a few seconds for deployment to register
- name: Wait for deployment to start
run: |
sleep 10
echo "Deployment started! wait for 5 min and try opening https://randomchat-hfta.onrender.com"