* build(deps): bump org.springframework.boot:spring-boot-starter-parent Bumps [org.springframework.boot:spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 3.5.5 to 3.5.6. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.5.5...v3.5.6) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-parent dependency-version: 3.5.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump org.apache.maven.plugins:maven-javadoc-plugin Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.11.3 to 3.12.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.11.3...maven-javadoc-plugin-3.12.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-version: 3.12.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump com.puppycrawl.tools:checkstyle in /server Bumps [com.puppycrawl.tools:checkstyle](https://github.com/checkstyle/checkstyle) from 11.0.1 to 11.1.0. - [Release notes](https://github.com/checkstyle/checkstyle/releases) - [Commits](https://github.com/checkstyle/checkstyle/compare/checkstyle-11.0.1...checkstyle-11.1.0) --- updated-dependencies: - dependency-name: com.puppycrawl.tools:checkstyle dependency-version: 11.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump actions/cache from 4.2.4 to 4.3.0 Bumps [actions/cache](https://github.com/actions/cache) from 4.2.4 to 4.3.0. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v4.2.4...v4.3.0) --- updated-dependencies: - dependency-name: actions/cache dependency-version: 4.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump org.hibernate.orm.tooling:hibernate-enhance-maven-plugin Bumps [org.hibernate.orm.tooling:hibernate-enhance-maven-plugin](https://github.com/hibernate/hibernate-orm) from 6.6.29.Final to 6.6.31.Final. - [Release notes](https://github.com/hibernate/hibernate-orm/releases) - [Changelog](https://github.com/hibernate/hibernate-orm/blob/6.6.31/changelog.txt) - [Commits](https://github.com/hibernate/hibernate-orm/compare/6.6.29...6.6.31) --- updated-dependencies: - dependency-name: org.hibernate.orm.tooling:hibernate-enhance-maven-plugin dependency-version: 6.6.31.Final dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump org.apache.maven.plugins:maven-enforcer-plugin Bumps [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.6.1 to 3.6.2. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.6.1...enforcer-3.6.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-version: 3.6.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * feat: dependencies bump * feat: improve prod and logs * fix: AuthService max length of 100 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
177 lines
6.2 KiB
YAML
177 lines
6.2 KiB
YAML
name: Main Tasknote-api
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'server/**/*.java'
|
|
- 'server/**/*.xml'
|
|
- 'server/Dockerfile'
|
|
|
|
jobs:
|
|
java-code-checks:
|
|
name: Tasknote-api Code Checks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
java-version: '17'
|
|
distribution: 'temurin'
|
|
cache: 'maven'
|
|
|
|
- name: Cache SonarQube Cloud packages
|
|
uses: actions/cache@v4.3.0
|
|
with:
|
|
path: ~/.sonar/cache
|
|
key: ${{ runner.os }}-sonar
|
|
restore-keys: ${{ runner.os }}-sonar
|
|
|
|
- name: Cache Maven packages
|
|
uses: actions/cache@v4.3.0
|
|
with:
|
|
path: ~/.m2
|
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
|
restore-keys: ${{ runner.os }}-m2
|
|
|
|
- name: Build with Maven
|
|
run: cd server && ./mvnw --no-transfer-progress clean compile -DskipTests
|
|
|
|
- name: Google Checkstyle
|
|
run: cd server && ./mvnw --no-transfer-progress checkstyle:checkstyle -Dskip.checkstyle=false
|
|
|
|
- name: All Tests
|
|
run: cd server && ./mvnw --no-transfer-progress clean verify -P tests --file pom.xml
|
|
|
|
- name: Sonar Analysis
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_SERVER }}
|
|
run: |
|
|
cd server
|
|
./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist_server -Dsonar.coverage.jacoco.xmlReportPaths=target/coverage-reports/merged-test-report/jacoco.xml -Dsonar.exclusions=**/config/**,**/entity/**,**/exception/**,**/filter/**,**/**Builder*,**/RestExceptionEndpoint.*,**/JavaApiApiApplication.*
|
|
|
|
image-promotion-and-deploy:
|
|
name: Image promotion and deployment
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DEPLOY_DOMAIN: ${{ vars.DEPLOY_DOMAIN }}
|
|
GHCR_USERNAME: ${{ vars.GHCR_USERNAME }}
|
|
GHCR_PASSWORD: ${{ secrets.GHCR_PASSWORD }}
|
|
API_KEY: ${{ secrets.DOKPLOY_API_KEY }}
|
|
SERVER_APPID: ${{ secrets.PROD_API_CLIENT_ID }}
|
|
steps:
|
|
- uses: docker/login-action@v3
|
|
name: Login to GitHub Container Registry
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Pull image with source tag
|
|
run: docker pull ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:candidate
|
|
|
|
- name: Extract PR number using docker inspect
|
|
id: inspect
|
|
run: |
|
|
SOURCE_PR=$(docker inspect ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:candidate | jq -r '.[0].Config.Env[] | select(startswith("SOURCE_PR="))' | sed -n 's/SOURCE_PR=\(v[0-9]*\).*/\1/p')
|
|
echo "SOURCE_PR=$SOURCE_PR" >> $GITHUB_ENV
|
|
echo "source_pr=$SOURCE_PR" >> $GITHUB_OUTPUT
|
|
|
|
- name: Re-tag the image
|
|
run: |
|
|
docker tag ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:candidate ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:prod-${{ steps.inspect.outputs.source_pr }}
|
|
docker tag ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:candidate ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:latest
|
|
|
|
- name: Push new tag
|
|
run: docker push --all-tags ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api
|
|
|
|
- name: Checking cURL version
|
|
run: curl --version
|
|
|
|
- name: Update image tag to be deployed
|
|
uses: nick-fields/retry@v3.0.2
|
|
with:
|
|
timeout_minutes: 2
|
|
max_attempts: 3
|
|
command: |
|
|
response=$(curl -X POST \
|
|
"${DEPLOY_DOMAIN}/api/application.saveDockerProvider" \
|
|
--max-time 30 \
|
|
-H "accept: application/json" \
|
|
-H "Content-Type: application/json" \
|
|
-H "x-api-key: ${API_KEY}" \
|
|
-d '{
|
|
"dockerImage": "ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:prod-${{ steps.inspect.outputs.source_pr }}",
|
|
"applicationId": "'"${SERVER_APPID}"'",
|
|
"username": "'"${GHCR_USERNAME}"'",
|
|
"password": "'"${GHCR_PASSWORD}"'",
|
|
"registryUrl": "ghcr.io"
|
|
}' \
|
|
-w "\n%{http_code}" \
|
|
-s)
|
|
|
|
status_code=$(echo "$response" | tail -n1)
|
|
echo "Status code: $status_code"
|
|
|
|
if [ "$status_code" != "200" ]; then
|
|
body=$(echo "$response" | sed '$d')
|
|
|
|
echo "Update failed with status code $status_code"
|
|
echo -e "Response body: $body"
|
|
exit 1
|
|
else
|
|
echo "Updated succeeded!"
|
|
fi
|
|
|
|
- name: Trigger Deployment
|
|
uses: nick-fields/retry@v3.0.2
|
|
with:
|
|
timeout_minutes: 2
|
|
max_attempts: 3
|
|
command: |
|
|
sleep 15
|
|
|
|
response=$(curl -X POST \
|
|
"${DEPLOY_DOMAIN}/api/application.deploy" \
|
|
--max-time 30 \
|
|
-H "accept: application/json" \
|
|
-H "x-api-key: ${API_KEY}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"applicationId\":\"${SERVER_APPID}\"}" \
|
|
-w "\n%{http_code}" \
|
|
-s)
|
|
|
|
status_code=$(echo "$response" | tail -n1)
|
|
echo "Status code: $status_code"
|
|
|
|
if [ "$status_code" != "200" ]; then
|
|
body=$(echo "$response" | sed '$d')
|
|
|
|
echo "Deployment failed with status code $status_code"
|
|
echo "Response body: $body"
|
|
exit 1
|
|
else
|
|
echo "Deployment succeeded!"
|
|
fi
|
|
|
|
- name: Verify deployment
|
|
run: |
|
|
# Wait for deployment to complete
|
|
sleep 15
|
|
|
|
if ! curl -s -f "${{ vars.API_PROD_URL }}/actuator/health"; then
|
|
echo "Prod environment is not healthy"
|
|
exit 1
|
|
else
|
|
echo "Prod environment is healthy"
|
|
fi
|