Compare commits

..

No commits in common. "main" and "Dev" have entirely different histories.
main ... Dev

16 changed files with 1972 additions and 7297 deletions

View file

@ -1,101 +1,95 @@
name: API Deployment Container name: API Deployment Container
on: on:
workflow_dispatch: {} workflow_dispatch: {}
pull_request: pull_request:
branches: branches:
- main - main
types: types:
- opened - opened
- reopened - reopened
- synchronize - synchronize
- ready_for_review - ready_for_review
paths: push:
- api/** branches:
push: - main
branches: paths:
- main - api/**
paths: jobs:
- api/** determine-workflow:
jobs: runs-on: 'ubuntu-latest'
determine-workflow: outputs:
runs-on: 'ubuntu-latest' workflow_type: ${{ steps.workflow.outputs.workflow_type }}
outputs: workflow_envs: ${{ steps.workflow.outputs.workflow_envs }}
workflow_type: ${{ steps.workflow.outputs.workflow_type }} release_type: ${{ steps.workflow.outputs.release_type }}
workflow_envs: ${{ steps.workflow.outputs.workflow_envs }} current_version: ${{ steps.version.outputs.current_version }}
release_type: ${{ steps.workflow.outputs.release_type }} steps:
current_version: ${{ steps.version.outputs.current_version }} - name: Checkout Code
steps: uses: actions/checkout@v4
- name: Checkout Code - name: Determine Workflow
uses: actions/checkout@v4 id: workflow
- name: Determine Workflow shell: bash
id: workflow run: |
shell: bash event=${{ github.event_name }}
run: | workflow_type='dev';
event=${{ github.event_name }} workflow_envs='["dev"]'
workflow_type='dev'; if [[ $event == 'workflow_dispatch' && '${{ github.ref_name }}' == 'main' ]];
workflow_envs='["dev"]' then
if [[ $event == 'workflow_dispatch' && '${{ github.ref_name }}' == 'main' ]]; echo "in if statement"
then workflow_type='release';
echo "in if statement" workflow_envs='["prod"]'
workflow_type='release'; fi
workflow_envs='["prod"]'
fi echo "workflow_type=$workflow_type" >> $GITHUB_OUTPUT
echo "workflow_envs=$workflow_envs" >> $GITHUB_OUTPUT
echo "workflow_type=$workflow_type" >> $GITHUB_OUTPUT
echo "workflow_envs=$workflow_envs" >> $GITHUB_OUTPUT echo "Running $workflow_type pipeline in environments: $workflow_envs" >> $GITHUB_STEP_SUMMARY
- name: Extract Version
echo "Running $workflow_type pipeline in environments: $workflow_envs" >> $GITHUB_STEP_SUMMARY id: version
- name: Extract Version shell: bash
id: version run: |
shell: bash version=$(jq -r '.version' api/package.json)
run: | echo "current_version=$version" >> "$GITHUB_OUTPUT"
version=$(jq -r '.version' api/package.json) nonprod-deploy:
echo "current_version=$version" >> "$GITHUB_OUTPUT" needs: determine-workflow
nonprod-deploy: if: needs.determine-workflow.outputs.workflow_type != 'release'
needs: determine-workflow strategy:
if: needs.determine-workflow.outputs.workflow_type != 'release' max-parallel: 1
strategy: matrix:
max-parallel: 1 env: ${{ fromJson(needs.determine-workflow.outputs.workflow_envs) }}
matrix: uses: ./.github/workflows/api-deploy-nonprod.yml
env: ${{ fromJson(needs.determine-workflow.outputs.workflow_envs) }} with:
uses: ./.github/workflows/api-deploy-nonprod.yml environments: ${{ matrix.env }}
with: workflow_type: ${{ needs.determine-workflow.outputs.workflow_type }}
environments: ${{ matrix.env }} branch: ${{ github.head_ref || github.ref_name }}
workflow_type: ${{ needs.determine-workflow.outputs.workflow_type }} current_version: ${{ needs.determine-workflow.outputs.current_version }}
branch: ${{ github.head_ref || github.ref_name }} secrets:
current_version: ${{ needs.determine-workflow.outputs.current_version }} DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
secrets: DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} TEST: ${{ secrets.TEST }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} COOLIFY_WEBHOOK_API: ${{ secrets.COOLIFY_WEBHOOK_API }}
TEST: ${{ secrets.TEST }} COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
TEAMCITY_API_ID: ${{ secrets.TEAMCITY_API_ID }} permissions:
TEAMCITY_URL: ${{ secrets.TEAMCITY_URL }} contents: read
TEAMCITY_USERNAME: ${{ secrets.TEAMCITY_USERNAME }} packages: write
TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }} prod-deploy:
permissions: needs: determine-workflow
contents: read if: needs.determine-workflow.outputs.workflow_type == 'release'
packages: write strategy:
prod-deploy: max-parallel: 1
needs: determine-workflow matrix:
if: needs.determine-workflow.outputs.workflow_type == 'release' env: ${{ fromJson(needs.determine-workflow.outputs.workflow_envs) }}
strategy: uses: ./.github/workflows/api-deploy-prod.yml
max-parallel: 1 with:
matrix: environments: ${{ matrix.env }}
env: ${{ fromJson(needs.determine-workflow.outputs.workflow_envs) }} workflow_type: ${{ needs.determine-workflow.outputs.workflow_type }}
uses: ./.github/workflows/api-deploy-prod.yml branch: ${{ github.head_ref || github.ref_name }}
with: current_version: ${{ needs.determine-workflow.outputs.current_version }}
environments: ${{ matrix.env }} secrets:
workflow_type: ${{ needs.determine-workflow.outputs.workflow_type }} DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
branch: ${{ github.head_ref || github.ref_name }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
current_version: ${{ needs.determine-workflow.outputs.current_version }} TEST: ${{ secrets.TEST }}
secrets: COOLIFY_WEBHOOK_API: ${{ secrets.COOLIFY_WEBHOOK_API }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} permissions:
TEST: ${{ secrets.TEST }} contents: read
TEAMCITY_API_ID: ${{ secrets.TEAMCITY_API_ID }} packages: write
TEAMCITY_URL: ${{ secrets.TEAMCITY_URL }}
TEAMCITY_USERNAME: ${{ secrets.TEAMCITY_USERNAME }}
TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }}
permissions:
contents: read
packages: write

View file

@ -22,10 +22,8 @@ on:
DOCKERHUB_USER: {} DOCKERHUB_USER: {}
DOCKERHUB_TOKEN: {} DOCKERHUB_TOKEN: {}
TEST: {} TEST: {}
TEAMCITY_API_ID: {} COOLIFY_WEBHOOK_API: {}
TEAMCITY_URL: {} COOLIFY_TOKEN: {}
TEAMCITY_USERNAME: {}
TEAMCITY_PASSWORD: {}
jobs: jobs:
check-inputs: check-inputs:
runs-on: 'ubuntu-latest' runs-on: 'ubuntu-latest'
@ -33,29 +31,17 @@ jobs:
steps: steps:
- name: Check secrets present - name: Check secrets present
run: | run: |
if [[ -z "${{ secrets.TEAMCITY_API_ID }}" ]]; then if [[ -z "${{ secrets.COOLIFY_WEBHOOK_API }}" ]]; then
echo "TEAMCITY_API_ID secret is empty or missing" echo "COOLIFY_WEBHOOK_API secret is empty or missing"
exit 1 exit 1
else else
echo "TEAMCITY_API_ID secret is set" echo "COOLIFY_WEBHOOK_API secret is set"
fi fi
if [[ -z "${{ secrets.TEAMCITY_URL }}" ]]; then if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then
echo "TEAMCITY_URL secret is empty or missing" echo "COOLIFY_TOKEN secret is empty or missing"
exit 1 exit 1
else else
echo "TEAMCITY_URL secret is set" echo "COOLIFY_TOKEN secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_USERNAME }}" ]]; then
echo "TEAMCITY_USERNAME secret is empty or missing"
exit 1
else
echo "TEAMCITY_USERNAME secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_PASSWORD }}" ]]; then
echo "TEAMCITY_PASSWORD secret is empty or missing"
exit 1
else
echo "TEAMCITY_PASSWORD secret is set"
fi fi
if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then
echo "DOCKERHUB_USER secret is empty or missing" echo "DOCKERHUB_USER secret is empty or missing"
@ -102,12 +88,7 @@ jobs:
contents: read contents: read
packages: write packages: write
steps: steps:
- name: Deploy to Team City - name: Deploy to Coolify
run: | run: |
curl -u ${{ secrets.TEAMCITY_USERNAME }}:${{ secrets.TEAMCITY_PASSWORD }} \ curl '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
-X POST \
-H "Content-Type: application/json" \
-d '{"buildType": {"id": "${{ secrets.TEAMCITY_API_ID }}"}}' \
"${{ secrets.TEAMCITY_URL }}/httpAuth/app/rest/buildQueue" > /dev/null

View file

@ -1,111 +1,94 @@
name: API Deployment Production name: API Deployment Production
on: on:
workflow_call: workflow_call:
inputs: inputs:
environments: environments:
type: string type: string
description: An optional list of environments to deploy to. description: An optional list of environments to deploy to.
default: 'prod' default: 'prod'
workflow_type: workflow_type:
type: string type: string
description: An optional string for workflow types. description: An optional string for workflow types.
default: 'prod' default: 'prod'
branch: branch:
type: string type: string
description: An optional string to define which branch to checkout. description: An optional string to define which branch to checkout.
default: 'main' default: 'main'
current_version: current_version:
type: string type: string
description: Current Version of the package.json. description: Current Version of the package.json.
default: '0.0.0' default: '0.0.0'
secrets: secrets:
DOCKERHUB_USER: {} DOCKERHUB_USER: {}
DOCKERHUB_TOKEN: {} DOCKERHUB_TOKEN: {}
TEST: {} TEST: {}
TEAMCITY_API_ID: {} COOLIFY_WEBHOOK_API: {}
TEAMCITY_URL: {} COOLIFY_TOKEN: {}
TEAMCITY_USERNAME: {} jobs:
TEAMCITY_PASSWORD: {} check-inputs:
jobs: runs-on: 'ubuntu-latest'
check-inputs: environment: ${{ inputs.environments }}
runs-on: 'ubuntu-latest' steps:
environment: ${{ inputs.environments }} - name: Check secrets present
steps: run: |
- name: Check secrets present if [[ -z "${{ secrets.COOLIFY_WEBHOOK_API }}" ]]; then
run: | echo "COOLIFY_WEBHOOK_API secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_API_ID }}" ]]; then exit 1
echo "TEAMCITY_API_ID secret is empty or missing" else
exit 1 echo "COOLIFY_WEBHOOK_API secret is set"
else fi
echo "TEAMCITY_API_ID secret is set" if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then
fi echo "COOLIFY_TOKEN secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_URL }}" ]]; then exit 1
echo "TEAMCITY_URL secret is empty or missing" else
exit 1 echo "COOLIFY_TOKEN secret is set"
else fi
echo "TEAMCITY_URL secret is set" if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then
fi echo "DOCKERHUB_USER secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_USERNAME }}" ]]; then exit 1
echo "TEAMCITY_USERNAME secret is empty or missing" else
exit 1 echo "DOCKERHUB_USER secret is set"
else fi
echo "TEAMCITY_USERNAME secret is set" if [[ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then
fi echo "DOCKERHUB_TOKEN secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_PASSWORD }}" ]]; then exit 1
echo "TEAMCITY_PASSWORD secret is empty or missing" else
exit 1 echo "DOCKERHUB_TOKEN secret is set"
else fi
echo "TEAMCITY_PASSWORD secret is set" echo "Current Version: ${{inputs.current_version}}"
fi build:
if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then needs: check-inputs
echo "DOCKERHUB_USER secret is empty or missing" if: needs.check-inputs.result == 'success' && inputs.workflow_type == 'release'
exit 1 environment: ${{ inputs.environments }}
else runs-on: 'ubuntu-latest'
echo "DOCKERHUB_USER secret is set" permissions:
fi contents: read
if [[ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then packages: write
echo "DOCKERHUB_TOKEN secret is empty or missing" steps:
exit 1 - name: Branch Checkout
else uses: actions/checkout@v4
echo "DOCKERHUB_TOKEN secret is set" with:
fi ref: ${{ inputs.branch }}
echo "Current Version: ${{inputs.current_version}}" - name: Login to Docker
build: uses: docker/login-action@v3
needs: check-inputs with:
if: needs.check-inputs.result == 'success' && inputs.workflow_type == 'release' registry: docker.io
environment: ${{ inputs.environments }} username: ${{ secrets.DOCKERHUB_USER }}
runs-on: 'ubuntu-latest' password: ${{ secrets.DOCKERHUB_TOKEN }}
permissions: - name: Docker Build Backend
contents: read run: docker build -f api/Dockerfile -t john4064/shiftsync:prod_api ./api --build-arg ENVIRONMENT=prod
packages: write - name: Docker Push Backend
steps: run: docker push john4064/shiftsync:prod_api
- name: Branch Checkout deploy:
uses: actions/checkout@v4 needs: build
with: if: needs.build.result == 'success' && inputs.workflow_type == 'release'
ref: ${{ inputs.branch }} environment: ${{ inputs.environments }}
- name: Login to Docker runs-on: 'ubuntu-latest'
uses: docker/login-action@v3 permissions:
with: contents: read
registry: docker.io packages: write
username: ${{ secrets.DOCKERHUB_USER }} steps:
password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Deploy to Coolify
- name: Docker Build Backend run: |
run: docker build -f api/Dockerfile -t john4064/shiftsync:prod_api ./api --build-arg ENVIRONMENT=prod curl '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
- name: Docker Push Backend
run: docker push john4064/shiftsync:prod_api
deploy:
needs: build
if: needs.build.result == 'success' && inputs.workflow_type == 'release'
environment: ${{ inputs.environments }}
runs-on: 'ubuntu-latest'
permissions:
contents: read
packages: write
steps:
- name: Deploy to Team City
run: |
curl -u ${{ secrets.TEAMCITY_USERNAME }}:${{ secrets.TEAMCITY_PASSWORD }} \
-X POST \
-H "Content-Type: application/json" \
-d '{"buildType": {"id": "${{ secrets.TEAMCITY_API_ID }}"}}' \
"${{ secrets.TEAMCITY_URL }}/httpAuth/app/rest/buildQueue" > /dev/null

View file

@ -1,19 +1,19 @@
name: PR Validation name: PR Validation
on: on:
pull_request: pull_request:
types: [opened] types: [opened]
permissions: permissions:
contents: read contents: read
jobs: jobs:
pr-validation: pr-validation:
permissions: permissions:
contents: read contents: read
pull-requests: write pull-requests: write
runs-on: 'ubuntu-latest' runs-on: ['self-hosted', 'pi']
steps: steps:
- uses: TimonVS/pr-labeler-action@v5 - uses: TimonVS/pr-labeler-action@v5
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/configs/pr-labeler-configuration.yml configuration-path: .github/configs/pr-labeler-configuration.yml

View file

@ -9,8 +9,6 @@ on:
- reopened - reopened
- synchronize - synchronize
- ready_for_review - ready_for_review
paths:
- web/**
push: push:
branches: branches:
- main - main
@ -18,7 +16,7 @@ on:
- web/** - web/**
jobs: jobs:
determine-workflow: determine-workflow:
runs-on: 'ubuntu-latest' runs-on: ['self-hosted','pi']
outputs: outputs:
workflow_type: ${{ steps.workflow.outputs.workflow_type }} workflow_type: ${{ steps.workflow.outputs.workflow_type }}
workflow_envs: ${{ steps.workflow.outputs.workflow_envs }} workflow_envs: ${{ steps.workflow.outputs.workflow_envs }}
@ -68,10 +66,8 @@ jobs:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
TEST: ${{ secrets.TEST }} TEST: ${{ secrets.TEST }}
TEAMCITY_WEB_ID: ${{ secrets.TEAMCITY_WEB_ID }} COOLIFY_WEBHOOK_WEB: ${{ secrets.COOLIFY_WEBHOOK_WEB }}
TEAMCITY_URL: ${{ secrets.TEAMCITY_URL }} COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
TEAMCITY_USERNAME: ${{ secrets.TEAMCITY_USERNAME }}
TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }}
permissions: permissions:
contents: read contents: read
packages: write packages: write
@ -92,10 +88,8 @@ jobs:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
TEST: ${{ secrets.TEST }} TEST: ${{ secrets.TEST }}
TEAMCITY_WEB_ID: ${{ secrets.TEAMCITY_WEB_ID }} COOLIFY_WEBHOOK_WEB: ${{ secrets.COOLIFY_WEBHOOK_WEB }}
TEAMCITY_URL: ${{ secrets.TEAMCITY_URL }} COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
TEAMCITY_USERNAME: ${{ secrets.TEAMCITY_USERNAME }}
TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }}
permissions: permissions:
contents: read contents: read
packages: write packages: write

View file

@ -1,111 +1,94 @@
name: Web Deployment Non-Production name: Web Deployment Non-Production
on: on:
workflow_call: workflow_call:
inputs: inputs:
environments: environments:
type: string type: string
description: An optional list of environments to deploy to. description: An optional list of environments to deploy to.
default: 'dev' default: 'dev'
workflow_type: workflow_type:
type: string type: string
description: An optional string for workflow types. description: An optional string for workflow types.
default: 'dev' default: 'dev'
branch: branch:
type: string type: string
description: An optional string to define which branch to checkout. description: An optional string to define which branch to checkout.
default: 'main' default: 'main'
current_version: current_version:
type: string type: string
description: Current Version of the package.json. description: Current Version of the package.json.
default: '0.0.0' default: '0.0.0'
secrets: secrets:
DOCKERHUB_USER: {} DOCKERHUB_USER: {}
DOCKERHUB_TOKEN: {} DOCKERHUB_TOKEN: {}
TEST: {} TEST: {}
TEAMCITY_WEB_ID: {} COOLIFY_WEBHOOK_WEB: {}
TEAMCITY_URL: {} COOLIFY_TOKEN: {}
TEAMCITY_USERNAME: {} jobs:
TEAMCITY_PASSWORD: {} check-inputs:
jobs: runs-on: 'ubuntu-latest'
check-inputs: environment: ${{ inputs.environments }}
runs-on: 'ubuntu-latest' steps:
environment: ${{ inputs.environments }} - name: Check secrets present
steps: run: |
- name: Check secrets present if [[ -z "${{ secrets.COOLIFY_WEBHOOK_WEB }}" ]]; then
run: | echo "COOLIFY_WEBHOOK_WEB secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_WEB_ID }}" ]]; then exit 1
echo "TEAMCITY_WEB_ID secret is empty or missing" else
exit 1 echo "COOLIFY_WEBHOOK_WEB secret is set"
else fi
echo "TEAMCITY_WEB_ID secret is set" if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then
fi echo "COOLIFY_TOKEN secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_URL }}" ]]; then exit 1
echo "TEAMCITY_URL secret is empty or missing" else
exit 1 echo "COOLIFY_TOKEN secret is set"
else fi
echo "TEAMCITY_URL secret is set" if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then
fi echo "DOCKERHUB_USER secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_USERNAME }}" ]]; then exit 1
echo "TEAMCITY_USERNAME secret is empty or missing" else
exit 1 echo "DOCKERHUB_USER secret is set"
else fi
echo "TEAMCITY_USERNAME secret is set" if [[ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then
fi echo "DOCKERHUB_TOKEN secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_PASSWORD }}" ]]; then exit 1
echo "TEAMCITY_PASSWORD secret is empty or missing" else
exit 1 echo "DOCKERHUB_TOKEN secret is set"
else fi
echo "TEAMCITY_PASSWORD secret is set" echo "Current Version: ${{inputs.current_version}}"
fi build:
if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then needs: check-inputs
echo "DOCKERHUB_USER secret is empty or missing" if: needs.check-inputs.result == 'success' && inputs.workflow_type != 'release'
exit 1 environment: ${{ inputs.environments }}
else runs-on: 'ubuntu-latest'
echo "DOCKERHUB_USER secret is set" permissions:
fi contents: read
if [[ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then packages: write
echo "DOCKERHUB_TOKEN secret is empty or missing" steps:
exit 1 - name: Branch Checkout
else uses: actions/checkout@v4
echo "DOCKERHUB_TOKEN secret is set" with:
fi ref: ${{ inputs.branch }}
echo "Current Version: ${{inputs.current_version}}" - name: Login to Docker
build: uses: docker/login-action@v3
needs: check-inputs with:
if: needs.check-inputs.result == 'success' && inputs.workflow_type != 'release' registry: docker.io
environment: ${{ inputs.environments }} username: ${{ secrets.DOCKERHUB_USER }}
runs-on: 'ubuntu-latest' password: ${{ secrets.DOCKERHUB_TOKEN }}
permissions: - name: Docker Build Backend
contents: read run: docker build -f web/Dockerfile -t john4064/shiftsync:latest_web ./web --build-arg ENVIRONMENT=dev
packages: write - name: Docker Push Backend
steps: run: docker push john4064/shiftsync:latest_web
- name: Branch Checkout deploy:
uses: actions/checkout@v4 needs: build
with: if: needs.build.result == 'success' && inputs.workflow_type != 'release'
ref: ${{ inputs.branch }} environment: ${{ inputs.environments }}
- name: Login to Docker runs-on: 'ubuntu-latest'
uses: docker/login-action@v3 permissions:
with: contents: read
registry: docker.io packages: write
username: ${{ secrets.DOCKERHUB_USER }} steps:
password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Deploy to Coolify
- name: Docker Build Backend run: |
run: docker build -f web/Dockerfile -t john4064/shiftsync:latest_web ./web --build-arg ENVIRONMENT=dev curl '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
- name: Docker Push Backend
run: docker push john4064/shiftsync:latest_web
deploy:
needs: build
if: needs.build.result == 'success' && inputs.workflow_type != 'release'
environment: ${{ inputs.environments }}
runs-on: 'ubuntu-latest'
permissions:
contents: read
packages: write
steps:
- name: Deploy to Team City
run: |
curl -u ${{ secrets.TEAMCITY_USERNAME }}:${{ secrets.TEAMCITY_PASSWORD }} \
-X POST \
-H "Content-Type: application/json" \
-d '{"buildType": {"id": "${{ secrets.TEAMCITY_WEB_ID }}"}}' \
"${{ secrets.TEAMCITY_URL }}/httpAuth/app/rest/buildQueue" > /dev/null

View file

@ -1,111 +1,94 @@
name: Web Deployment Production name: Web Deployment Production
on: on:
workflow_call: workflow_call:
inputs: inputs:
environments: environments:
type: string type: string
description: An optional list of environments to deploy to. description: An optional list of environments to deploy to.
default: 'prod' default: 'prod'
workflow_type: workflow_type:
type: string type: string
description: An optional string for workflow types. description: An optional string for workflow types.
default: 'prod' default: 'prod'
branch: branch:
type: string type: string
description: An optional string to define which branch to checkout. description: An optional string to define which branch to checkout.
default: 'main' default: 'main'
current_version: current_version:
type: string type: string
description: Current Version of the package.json. description: Current Version of the package.json.
default: '0.0.0' default: '0.0.0'
secrets: secrets:
DOCKERHUB_USER: {} DOCKERHUB_USER: {}
DOCKERHUB_TOKEN: {} DOCKERHUB_TOKEN: {}
TEST: {} TEST: {}
TEAMCITY_WEB_ID: {} COOLIFY_WEBHOOK_WEB: {}
TEAMCITY_URL: {} COOLIFY_TOKEN: {}
TEAMCITY_USERNAME: {} jobs:
TEAMCITY_PASSWORD: {} check-inputs:
jobs: runs-on: 'ubuntu-latest'
check-inputs: environment: ${{ inputs.environments }}
runs-on: 'ubuntu-latest' steps:
environment: ${{ inputs.environments }} - name: Check secrets present
steps: run: |
- name: Check secrets present if [[ -z "${{ secrets.COOLIFY_WEBHOOK_WEB }}" ]]; then
run: | echo "COOLIFY_WEBHOOK_WEB secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_WEB_ID }}" ]]; then exit 1
echo "TEAMCITY_WEB_ID secret is empty or missing" else
exit 1 echo "COOLIFY_WEBHOOK_WEB secret is set"
else fi
echo "TEAMCITY_WEB_ID secret is set" if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then
fi echo "COOLIFY_TOKEN secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_URL }}" ]]; then exit 1
echo "TEAMCITY_URL secret is empty or missing" else
exit 1 echo "COOLIFY_TOKEN secret is set"
else fi
echo "TEAMCITY_URL secret is set" if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then
fi echo "DOCKERHUB_USER secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_USERNAME }}" ]]; then exit 1
echo "TEAMCITY_USERNAME secret is empty or missing" else
exit 1 echo "DOCKERHUB_USER secret is set"
else fi
echo "TEAMCITY_USERNAME secret is set" if [[ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then
fi echo "DOCKERHUB_TOKEN secret is empty or missing"
if [[ -z "${{ secrets.TEAMCITY_PASSWORD }}" ]]; then exit 1
echo "TEAMCITY_PASSWORD secret is empty or missing" else
exit 1 echo "DOCKERHUB_TOKEN secret is set"
else fi
echo "TEAMCITY_PASSWORD secret is set" echo "Current Version: ${{inputs.current_version}}"
fi build:
if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then needs: check-inputs
echo "DOCKERHUB_USER secret is empty or missing" if: needs.check-inputs.result == 'success' && inputs.workflow_type == 'release'
exit 1 environment: ${{ inputs.environments }}
else runs-on: 'ubuntu-latest'
echo "DOCKERHUB_USER secret is set" permissions:
fi contents: read
if [[ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then packages: write
echo "DOCKERHUB_TOKEN secret is empty or missing" steps:
exit 1 - name: Branch Checkout
else uses: actions/checkout@v4
echo "DOCKERHUB_TOKEN secret is set" with:
fi ref: ${{ inputs.branch }}
echo "Current Version: ${{inputs.current_version}}" - name: Login to Docker
build: uses: docker/login-action@v3
needs: check-inputs with:
if: needs.check-inputs.result == 'success' && inputs.workflow_type == 'release' registry: docker.io
environment: ${{ inputs.environments }} username: ${{ secrets.DOCKERHUB_USER }}
runs-on: 'ubuntu-latest' password: ${{ secrets.DOCKERHUB_TOKEN }}
permissions: - name: Docker Build Backend
contents: read run: docker build -f web/Dockerfile -t john4064/shiftsync:prod_web ./web --build-arg ENVIRONMENT=prod
packages: write - name: Docker Push Backend
steps: run: docker push john4064/shiftsync:prod_web
- name: Branch Checkout deploy:
uses: actions/checkout@v4 needs: build
with: if: needs.build.result == 'success' && inputs.workflow_type == 'release'
ref: ${{ inputs.branch }} environment: ${{ inputs.environments }}
- name: Login to Docker runs-on: 'ubuntu-latest'
uses: docker/login-action@v3 permissions:
with: contents: read
registry: docker.io packages: write
username: ${{ secrets.DOCKERHUB_USER }} steps:
password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Deploy to Coolify
- name: Docker Build Backend run: |
run: docker build -f web/Dockerfile -t john4064/shiftsync:prod_web ./web --build-arg ENVIRONMENT=prod curl '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
- name: Docker Push Backend
run: docker push john4064/shiftsync:prod_web
deploy:
needs: build
if: needs.build.result == 'success' && inputs.workflow_type == 'release'
environment: ${{ inputs.environments }}
runs-on: 'ubuntu-latest'
permissions:
contents: read
packages: write
steps:
- name: Deploy to Team City
run: |
curl -u ${{ secrets.TEAMCITY_USERNAME }}:${{ secrets.TEAMCITY_PASSWORD }} \
-X POST \
-H "Content-Type: application/json" \
-d '{"buildType": {"id": "${{ secrets.TEAMCITY_WEB_ID }}"}}' \
"${{ secrets.TEAMCITY_URL }}/httpAuth/app/rest/buildQueue" > /dev/null

View file

@ -1,14 +1,14 @@
FROM node:20-alpine FROM node:20-alpine
WORKDIR /app WORKDIR /app
COPY ./package*.json ./ COPY ./package*.json ./
RUN npm ci RUN npm cache clean --force && npm install --no-audit --no-fund
COPY . ./ COPY . ./
EXPOSE 5172 EXPOSE 5172
EXPOSE 5170 EXPOSE 5170
CMD npm run dev CMD npm run dev

1403
api/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "shiftsync-website-api", "name": "shiftsync-website-api",
"version": "1.0.11", "version": "1.0.1",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {

View file

@ -1,7 +1,6 @@
import express from 'express'; import express from 'express';
import cors from 'cors'; import cors from 'cors';
import dotenv from 'dotenv'; import dotenv from 'dotenv';
import fs from 'fs/promises';
import { medicationRouter } from './services/medications/index.js'; import { medicationRouter } from './services/medications/index.js';
import { shiftsRouter } from './services/shifts/index.js'; import { shiftsRouter } from './services/shifts/index.js';
import { shiftRunQuery } from './services/shiftConnection.js'; import { shiftRunQuery } from './services/shiftConnection.js';
@ -46,12 +45,9 @@ app.get('/api/db-health', async (req, res) => {
res.status(500).json({ connected: false, error: err.message }); res.status(500).json({ connected: false, error: err.message });
} }
}); });
app.get('/api/version', async (req, res) => { app.get('/api/version', async (req, res) => {
try { try {
const packageData = await fs.readFile('./package.json', 'utf8'); res.json('1.0.1');
const pkg = JSON.parse(packageData);
res.json(pkg.version);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
res.status(500).json({ connected: false, error: err.message }); res.status(500).json({ connected: false, error: err.message });

3040
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,17 @@
FROM node:20-alpine FROM node:20-alpine
WORKDIR /app WORKDIR /app
COPY ./package*.json ./ COPY ./package*.json ./
RUN npm ci RUN npm cache clean --force && npm install --no-audit --no-fund
COPY . ./ COPY . ./
EXPOSE 5173 EXPOSE 5173
EXPOSE 5171 EXPOSE 5171
ARG ENVIRONMENT ARG ENVIRONMENT
ENV ENVIRONMENT ${ENVIRONMENT} ENV ENVIRONMENT ${ENVIRONMENT}
CMD npm run ${ENVIRONMENT} CMD npm run ${ENVIRONMENT}

3845
web/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
{ {
"name": "shiftsync-website-web", "name": "shiftsync-website-web",
"version": "1.0.10",
"private": true, "private": true,
"version": "1.0.5",
"type": "module", "type": "module",
"scripts": { "scripts": {
"local": "vite", "local": "vite",

View file

@ -14,11 +14,10 @@ export const Home = () => {
}, []); }, []);
return ( return (
<div > <div>
<h1>Home Page</h1> <h1>Home Page</h1>
<Link to="/settings">Go to Settings</Link> <Link to="/settings">Go to Settings</Link>
<p>Version: {pkg.version}</p> <p>Version: {pkg.version}</p>
<p>This site does nothing</p>
</div> </div>
); );
}; };