46 lines
1.3 KiB
YAML
46 lines
1.3 KiB
YAML
name: AS Talange CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
test:
|
|
name: Build & Run Unit Tests
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Clone repository
|
|
run: |
|
|
SERVER_URL="${{ github.server_url }}"
|
|
SERVER_NO_PROTO="${SERVER_URL#http://}"
|
|
SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}"
|
|
git clone --depth 1 "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" .
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Run Maven Tests in Docker
|
|
run: |
|
|
docker run --rm \
|
|
-v ${{ github.workspace }}:/as-talange \
|
|
-w /as-talange \
|
|
maven:3.9.6-eclipse-temurin-21 \
|
|
mvn clean test
|
|
|
|
deploy:
|
|
name: Build & Run in Docker Container
|
|
needs: test
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Clone repository
|
|
run: |
|
|
SERVER_URL="${{ github.server_url }}"
|
|
SERVER_NO_PROTO="${SERVER_URL#http://}"
|
|
SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}"
|
|
git clone --depth 1 "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" .
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Deploy with Docker Compose
|
|
run: |
|
|
docker compose down app || true
|
|
docker compose up -d --build app
|