Skip to content
Merged

V3 #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 35 additions & 33 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: |
docker buildx build --platform linux/amd64 \
-t ${{ secrets.DOCKER_USERNAME }}/hscodes:${{ github.run_number }} \
--file Autumn.UI/Dockerfile \
--file Dockerfile \
--push .

- name: Set up SSH agent
Expand All @@ -44,44 +44,46 @@ jobs:
run: |
if [ "${{ github.event_name }}" == "push" ]; then
ENVIRONMENT="production"
BRANCH="main" # Deploy from the main branch for production
BRANCH="main"
DEPLOY_DIR="/root/hscodes"
COMPOSE_FILE="docker-compose.prod.yml"
CONNECTION_STRING="${{ secrets.PROD_CONNECTION_STRING }}"
else
ENVIRONMENT="staging"
BRANCH="${{ github.head_ref }}" # Deploy from the PR branch for staging
BRANCH="${{ github.head_ref }}"
DEPLOY_DIR="/root/hscodes-staging"
COMPOSE_FILE="docker-compose.staging.yml"
CONNECTION_STRING="${{ secrets.STAGING_CONNECTION_STRING }}"
fi

RUN_NUMBER=${{ github.run_number }} # Get the GitHub Run Number
RUN_NUMBER=${{ github.run_number }}
echo "Deploying to $ENVIRONMENT environment..."

# Write .env file locally and upload to VPS
cat > /tmp/deploy.env << EOF
AUTH0_DOMAIN=${{ secrets.AUTH0_DOMAIN }}
AUTH0_AUDIENCE=${{ secrets.AUTH0_AUDIENCE }}
GROQAPIKEY=${{ secrets.GROQAPIKEY }}
CONNECTION_STRING=${CONNECTION_STRING}
GITHUB_RUN_NUMBER=${RUN_NUMBER}
EOF
# Remove leading whitespace from heredoc
sed -i 's/^[[:space:]]*//' /tmp/deploy.env

ssh ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} "mkdir -p ${DEPLOY_DIR}"
scp /tmp/deploy.env ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }}:${DEPLOY_DIR}/.env

# Deploy on VPS
ssh ${{ secrets.VPS_USERNAME }}@${{ secrets.VPS_HOST }} "
if [ '$ENVIRONMENT' == 'production' ]; then
mkdir -p /root/hscodes &&
cd /root/hscodes;
else
mkdir -p /root/hscodes-staging &&
cd /root/hscodes-staging;
fi &&
if [ ! -d .git ]; then
echo 'Directory is not a git repository. Cloning...';
git clone https://github.com/samabos/hscodesdotnet.git .;
fi;
cd ${DEPLOY_DIR} &&
if [ ! -d .git ]; then
echo 'Cloning repository...' &&
git clone https://github.com/samabos/hscodesdotnet.git .;
fi &&
git reset --hard HEAD &&
git fetch origin $BRANCH &&
git checkout $BRANCH &&
git pull origin $BRANCH &&
if [ '$ENVIRONMENT' == 'production' ]; then
export AUTH0_DOMAIN='${{ secrets.AUTH0_DOMAIN }}' &&
export AUTH0_CLIENTID='${{ secrets.AUTH0_CLIENTID }}' &&
export CONNECTION_STRING='${{ secrets.PROD_CONNECTION_STRING }}' &&
export GITHUB_RUN_NUMBER=$RUN_NUMBER &&
docker-compose -f ./docker-compose.prod.yml down &&
docker-compose -f ./docker-compose.prod.yml up -d --build;
else
export AUTH0_DOMAIN='${{ secrets.AUTH0_DOMAIN }}' &&
export AUTH0_CLIENTID='${{ secrets.AUTH0_CLIENTID }}' &&
export CONNECTION_STRING='${{ secrets.STAGING_CONNECTION_STRING }}' &&
export GITHUB_RUN_NUMBER=$RUN_NUMBER &&
docker-compose -f ./docker-compose.staging.yml up -d --build;
fi
git fetch origin ${BRANCH} &&
git checkout ${BRANCH} &&
git pull origin ${BRANCH} &&
docker compose -f ./${COMPOSE_FILE} down &&
docker compose -f ./${COMPOSE_FILE} up -d
"

11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,14 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml

# App settings with secrets
**/appsettings.json
**/appsettings.Development.json

# Claude Code
.claude/

# Temp files
nul
hs-codes-redesign.jsx
33 changes: 10 additions & 23 deletions Autumn.API/Autumn.API.csproj
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Controllers\V1\IdentityController.cs" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0" />
<PackageReference Include="AutoMapper" Version="14.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.3.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App">
<PrivateAssets Condition="'%(PackageReference.Version)' == ''">all</PrivateAssets>
<Publish Condition="'%(PackageReference.Version)' == ''">true</Publish>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="RestSharp" Version="106.10.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<ProjectReference Include="..\Autumn.Domain\Autumn.Domain.csproj" />
<ProjectReference Include="..\Autumn.UIML.Model\Autumn.UIML.Model.csproj" />
<ProjectReference Include="..\Autumn.BL\Autumn.Service.csproj" />
<ProjectReference Include="..\Autumn.Repository\Autumn.Infrastructure.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Autumn.Domain\Autumn.Domain.csproj">
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
</ProjectReference>
<ProjectReference Include="..\Autumn.UIML.Model\Autumn.UIML.Model.csproj">
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
</ProjectReference>
<ProjectReference Include="..\Autumn.BL\Autumn.BL.csproj">
<GlobalPropertiesToRemove></GlobalPropertiesToRemove>
</ProjectReference>
</ItemGroup>
</Project>
43 changes: 0 additions & 43 deletions Autumn.API/Contract/V1/ApiRoutes.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Autumn.API/Contract/V1/Requests/ClassifyCommodityRequest.cs

This file was deleted.

37 changes: 0 additions & 37 deletions Autumn.API/Contract/V1/Requests/DutyRequest.cs

This file was deleted.

15 changes: 0 additions & 15 deletions Autumn.API/Contract/V1/Requests/SearchRequest.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Autumn.API/Contract/V1/Requests/UserRequest.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Autumn.API/Contract/V1/Responses/AuthFailedResponse.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Autumn.API/Contract/V1/Responses/AuthSuccessResponse.cs

This file was deleted.

32 changes: 0 additions & 32 deletions Autumn.API/Contract/V1/Responses/ClassifyCommodityResponse.cs

This file was deleted.

14 changes: 0 additions & 14 deletions Autumn.API/Contract/V1/Responses/CurrencyObject.cs

This file was deleted.

16 changes: 0 additions & 16 deletions Autumn.API/Contract/V1/Responses/CurrencyResponse.cs

This file was deleted.

23 changes: 0 additions & 23 deletions Autumn.API/Contract/V1/Responses/CustomsTariffObject.cs

This file was deleted.

Loading