* build(deps): bump SonarSource/sonarqube-scan-action from 5.2.0 to 5.3.0 Bumps [SonarSource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action) from 5.2.0 to 5.3.0. - [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases) - [Commits](https://github.com/sonarsource/sonarqube-scan-action/compare/v5.2.0...v5.3.0) --- updated-dependencies: - dependency-name: SonarSource/sonarqube-scan-action dependency-version: 5.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps-dev): bump eslint from 9.31.0 to 9.32.0 in /client Bumps [eslint](https://github.com/eslint/eslint) from 9.31.0 to 9.32.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v9.31.0...v9.32.0) --- updated-dependencies: - dependency-name: eslint dependency-version: 9.32.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps-dev): bump eslint-config-prettier in /client Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 10.1.5 to 10.1.8. - [Release notes](https://github.com/prettier/eslint-config-prettier/releases) - [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-config-prettier/compare/v10.1.5...v10.1.8) --- updated-dependencies: - dependency-name: eslint-config-prettier dependency-version: 10.1.8 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump react from 19.1.0 to 19.1.1 in /client Bumps [react](https://github.com/facebook/react/tree/HEAD/packages/react) from 19.1.0 to 19.1.1. - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v19.1.1/packages/react) --- updated-dependencies: - dependency-name: react dependency-version: 19.1.1 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.0 to 3.6.1. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.6.0...enforcer-3.6.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-version: 3.6.1 dependency-type: direct:production update-type: version-update:semver-patch ... 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.21.Final to 6.6.23.Final. - [Release notes](https://github.com/hibernate/hibernate-orm/releases) - [Changelog](https://github.com/hibernate/hibernate-orm/blob/6.6.23/changelog.txt) - [Commits](https://github.com/hibernate/hibernate-orm/compare/6.6.21...6.6.23) --- updated-dependencies: - dependency-name: org.hibernate.orm.tooling:hibernate-enhance-maven-plugin dependency-version: 6.6.23.Final dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps-dev): bump eslint-plugin-jsdoc in /client Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 51.3.4 to 52.0.0. - [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases) - [Changelog](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.releaserc) - [Commits](https://github.com/gajus/eslint-plugin-jsdoc/compare/v51.3.4...v52.0.0) --- updated-dependencies: - dependency-name: eslint-plugin-jsdoc dependency-version: 52.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * 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.3 to 3.5.4. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.5.3...v3.5.4) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-parent dependency-version: 3.5.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump react-i18next from 15.6.0 to 15.6.1 in /client Bumps [react-i18next](https://github.com/i18next/react-i18next) from 15.6.0 to 15.6.1. - [Changelog](https://github.com/i18next/react-i18next/blob/master/CHANGELOG.md) - [Commits](https://github.com/i18next/react-i18next/compare/v15.6.0...v15.6.1) --- updated-dependencies: - dependency-name: react-i18next dependency-version: 15.6.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * feat: make react-dom the same version as react --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
172 lines
5.7 KiB
YAML
172 lines
5.7 KiB
YAML
name: Main Client
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'client/**/*.html'
|
|
- 'client/**/*.png'
|
|
- 'client/**/*.json'
|
|
- 'client/**/*.txt'
|
|
- 'client/**/*.ts'
|
|
- 'client/**/*.tsx'
|
|
- 'client/**/*.js'
|
|
- 'client/Dockerfile'
|
|
- 'client/Caddyfile'
|
|
|
|
jobs:
|
|
client-code-checks:
|
|
name: Client Code Checks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
- name: Clean and Install
|
|
run: cd client && npm ci
|
|
- name: Build
|
|
run: cd client && npm run build
|
|
- name: Lint
|
|
run: cd client && npm run lint
|
|
- name: Unit tests
|
|
run: cd client && npm run test:coverage
|
|
- name: SonarQube Scan
|
|
uses: SonarSource/sonarqube-scan-action@v5.3.0
|
|
with:
|
|
projectBaseDir: client
|
|
args: >
|
|
-Dsonar.organization=ricardo-campos-org
|
|
-Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist_client
|
|
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
-Dsonar.typescript.tsconfigPaths=tsconfig.json
|
|
-Dsonar.sources=src/
|
|
-Dsonar.exclusions=src/__test__/**
|
|
-Dsonar.tests=src/__test__/
|
|
-Dsonar.verbose=false
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
|
|
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 }}
|
|
CLIENT_APPID: ${{ secrets.PROD_WEB_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/client:candidate
|
|
|
|
- name: Extract PR number using docker inspect
|
|
id: inspect
|
|
run: |
|
|
SOURCE_PR=$(docker inspect ghcr.io/ricardo-campos-org/react-typescript-todolist/client: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/client:candidate ghcr.io/ricardo-campos-org/react-typescript-todolist/client:prod-${{ steps.inspect.outputs.source_pr }}
|
|
|
|
- name: Push new tag
|
|
run: docker push ghcr.io/ricardo-campos-org/react-typescript-todolist/client:prod-${{ steps.inspect.outputs.source_pr }}
|
|
|
|
- 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/client:prod-${{ steps.inspect.outputs.source_pr }}",
|
|
"applicationId": "'"${CLIENT_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\":\"${CLIENT_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 -e "Response body: $body"
|
|
exit 1
|
|
else
|
|
echo "Deployment succeeded!"
|
|
fi
|
|
|
|
- name: Verifying post deployment
|
|
run: |
|
|
# Wait for deployment to complete
|
|
sleep 15
|
|
|
|
if ! curl -s -f "${{ vars.CLIENT_PROD_URL }}/" > /dev/null; then
|
|
echo "Prod environment is not healthy"
|
|
exit 1
|
|
else
|
|
echo "Prod environment is healthy"
|
|
fi
|