Pull Request CI-Backend / Checks (pull_request) Successful in 3m48s
Pull Request CI-Backend / Build & Push (pull_request) Failing after 6m45s
Pull Request CI-Frontend / Checks (pull_request) Failing after 1m22s
Pull Request CI-Frontend / Build & Push (pull_request) Has been skipped
95 lines
3.6 KiB
YAML
95 lines
3.6 KiB
YAML
name: Pull Request CI-Backend
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
branches:
|
|
- 'main'
|
|
paths:
|
|
- 'server/**/*.java'
|
|
- 'server/**/*.xml'
|
|
- 'server/pom.xml'
|
|
- 'server/**/*.yml'
|
|
- '.github/workflows/ci-pr-backend.yml'
|
|
|
|
jobs:
|
|
run-checks:
|
|
name: Checks
|
|
runs-on: graalvm-25
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Run Check Style
|
|
working-directory: ./server
|
|
run: ./mvnw --no-transfer-progress checkstyle:check -Dcheckstyle.skip=false
|
|
|
|
- name: Run build
|
|
working-directory: ./server
|
|
run: ./mvnw --no-transfer-progress clean compile -DskipTests
|
|
|
|
- name: Run tests
|
|
working-directory: ./server
|
|
run: ./mvnw --no-transfer-progress clean verify -P tests --file pom.xml
|
|
|
|
build-and-push:
|
|
name: Build & Push
|
|
runs-on: graalvm-25
|
|
needs: ["run-checks"]
|
|
permissions:
|
|
contents: read
|
|
deployments: write
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set lowercase repo name
|
|
id: repo
|
|
run: echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Log in to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: lightroasted.vps-kinghost.net
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build Docker image with Spring Boot
|
|
working-directory: ./server
|
|
run: |
|
|
./mvnw -Pnative -DskipTests spring-boot:build-image \
|
|
-Dspring-boot.build-image.imageName=lightroasted.vps-kinghost.net/${{ steps.repo.outputs.name }}/api:latest \
|
|
-Dspring-boot.build-image.builder=paketobuildpacks/builder-jammy-tiny:latest
|
|
|
|
- name: Tag and push Docker image
|
|
run: |
|
|
docker tag lightroasted.vps-kinghost.net/${{ steps.repo.outputs.name }}/api:latest lightroasted.vps-kinghost.net/${{ steps.repo.outputs.name }}/api:candidate
|
|
docker tag lightroasted.vps-kinghost.net/${{ steps.repo.outputs.name }}/api:latest lightroasted.vps-kinghost.net/${{ steps.repo.outputs.name }}/api:pr-${{ github.event.pull_request.number }}
|
|
docker push lightroasted.vps-kinghost.net/${{ steps.repo.outputs.name }}/api:candidate
|
|
docker push lightroasted.vps-kinghost.net/${{ steps.repo.outputs.name }}/api:pr-${{ github.event.pull_request.number }}
|
|
|
|
- name: Create Gitea deployment for staging
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
run: |
|
|
DEPLOY_ID=$(curl -s -X POST \
|
|
-H "Authorization: token ${{ secrets.REGISTRY_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
"https://lightroasted.vps-kinghost.net/api/v1/repos/${{ github.repository }}/deployments" \
|
|
-d "{\"ref\": \"${{ github.event.pull_request.head.sha }}\", \"environment\": \"staging\", \"description\": \"PR #${{ github.event.pull_request.number }} preview deployment\", \"transient_environment\": true, \"auto_merge\": false}" \
|
|
| jq -r '.id')
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${{ secrets.REGISTRY_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
"https://lightroasted.vps-kinghost.net/api/v1/repos/${{ github.repository }}/deployments/${DEPLOY_ID}/statuses" \
|
|
-d '{"state": "success", "environment_url": "https://tasknote-stg.darkroasted.vps-kinghost.net"}'
|