Skip to content

Commit

Permalink
update gh workflow for admin deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Oct 8, 2024
1 parent bf08e80 commit ffcc1e9
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
64 changes: 63 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,63 @@ jobs:
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ secrets.API_REPOSITORY_NAME }}:${{ github.sha }}
${{ steps.login-ecr.outputs.registry }}/${{ secrets.API_REPOSITORY_NAME }}:${{ needs.set_environment_name.outputs.env_name }}
build_admin:
needs: [ set_environment_name ]
environment:
name: ${{ needs.set_environment_name.outputs.env_name }}
runs-on: ubuntu-latest
name: Build Admin image and push to Amazon ECR
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: admin-changes
with:
filters: |
admin:
- 'admin/**'
- '.github/workflows/**'
- name: Configure AWS credentials
if: ${{ github.event_name == 'workflow_dispatch' || steps.admin-changes.outputs.admin == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PIPELINE_USER_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PIPELINE_USER_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
if: ${{ github.event_name == 'workflow_dispatch' || steps.admin-changes.outputs.admin == 'true' }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'

- name: Set up Docker Buildx
if: ${{ github.event_name == 'workflow_dispatch' || steps.admin-changes.outputs.admin == 'true' }}
uses: docker/setup-buildx-action@v3

- name: Build, tag, and push Admin image to Amazon ECR
if: ${{ github.event_name == 'workflow_dispatch' || steps.admin-changes.outputs.admin == 'true' }}
uses: docker/build-push-action@v6
with:
build-args: |
DB_HOST=${{ secrets.DB_HOST }}
DB_PORT=${{ secrets.DB_PORT }}
DB_NAME=${{ secrets.DB_NAME }}
DB_USERNAME=${{ secrets.DB_USERNAME }}
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
file: ./admin/Dockerfile
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ secrets.ADMIN_REPOSITORY_NAME }}:${{ github.sha }}
${{ steps.login-ecr.outputs.registry }}/${{ secrets.ADMIN_REPOSITORY_NAME }}:${{ needs.set_environment_name.outputs.env_name }}
deploy:
name: Deploy Services to Amazon EBS
Expand Down Expand Up @@ -179,6 +235,7 @@ jobs:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY_CLIENT: ${{ secrets.CLIENT_REPOSITORY_NAME }}
ECR_REPOSITORY_API: ${{ secrets.API_REPOSITORY_NAME }}
ECR_REPOSITORY_ADMIN: ${{ secrets.ADMIN_REPOSITORY_NAME }}
IMAGE_TAG: ${{ needs.set_environment_name.outputs.env_name }}
run: |
cat <<EOF >> docker-compose.yml
Expand All @@ -193,6 +250,11 @@ jobs:
restart: always
ports:
- 4000:4000
admin:
image: $ECR_REGISTRY/$ECR_REPOSITORY_ADMIN:$IMAGE_TAG
restart: always
ports:
- 1000:1000
nginx:
image: nginx
restart: always
Expand Down
10 changes: 10 additions & 0 deletions admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { User } from "@shared/entities/users/user.entity.js";
import { dataSource } from "./datasource.js";
import { CarbonInputEntity } from "@api/modules/model/entities/carbon-input.entity.js";
import { CostInput } from "@api/modules/model/entities/cost-input.entity.js";
import { Country } from "@api/modules/model/entities/country.entity.js";

AdminJS.registerAdapter({
Database: AdminJSTypeorm.Database,
Expand Down Expand Up @@ -38,6 +39,14 @@ const start = async () => {
icon: "Coins",
},
},
{
resource: Country,
name: "Country",
options: {
parent: databaseNavigation,
icon: "Globe",
},
},
{
resource: User,
options: {
Expand All @@ -47,6 +56,7 @@ const start = async () => {
},
{
resource: CarbonInputEntity,
name: "Andresito",
options: {
parent: databaseNavigation,
icon: "Cloud",
Expand Down

0 comments on commit ffcc1e9

Please sign in to comment.