* build(deps-dev): bump typescript-eslint from 8.26.0 to 8.26.1 in /client Bumps [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) from 8.26.0 to 8.26.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.26.1/packages/typescript-eslint) --- updated-dependencies: - dependency-name: typescript-eslint dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps-dev): bump prettier from 3.5.2 to 3.5.3 in /client Bumps [prettier](https://github.com/prettier/prettier) from 3.5.2 to 3.5.3. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/3.5.2...3.5.3) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): bump react-router from 7.2.0 to 7.3.0 in /client Bumps [react-router](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router) from 7.2.0 to 7.3.0. - [Release notes](https://github.com/remix-run/react-router/releases) - [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router/CHANGELOG.md) - [Commits](https://github.com/remix-run/react-router/commits/react-router@7.3.0/packages/react-router) --- updated-dependencies: - dependency-name: react-router dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps-dev): bump globals from 15.14.0 to 16.0.0 in /client Bumps [globals](https://github.com/sindresorhus/globals) from 15.14.0 to 16.0.0. - [Release notes](https://github.com/sindresorhus/globals/releases) - [Commits](https://github.com/sindresorhus/globals/compare/v15.14.0...v16.0.0) --- updated-dependencies: - dependency-name: globals dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps-dev): bump @types/react from 19.0.3 to 19.0.11 in /client Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 19.0.3 to 19.0.11. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react) --- updated-dependencies: - dependency-name: "@types/react" dependency-type: direct:development 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.10.Final to 6.6.11.Final. - [Release notes](https://github.com/hibernate/hibernate-orm/releases) - [Changelog](https://github.com/hibernate/hibernate-orm/blob/6.6.11/changelog.txt) - [Commits](https://github.com/hibernate/hibernate-orm/compare/6.6.10...6.6.11) --- updated-dependencies: - dependency-name: org.hibernate.orm.tooling:hibernate-enhance-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * hotfix: remove hard coded code --------- 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.0.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
|