Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.dev.env filter=git-crypt diff=git-crypt
.prod.env filter=git-crypt-PROD diff=git-crypt-PROD
.stage.env filter=git-crypt-STAGE diff=git-crypt-STAGE
.stage.env filter=git-crypt-STAGE diff=git-crypt-STAGE
.stage.aws.env filter=git-crypt-STAGE diff=git-crypt-STAGE
.prod.aws.env filter=git-crypt-PROD diff=git-crypt-PROD
65 changes: 65 additions & 0 deletions .github/workflows/aws-ui-cd-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: time-tracker-ui-cd-prod

on:
push:
branches:
- 'fast-api*'

jobs:
cd:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get the release_version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo $RELEASE_VERSION

- name: Unlock PROD secrets
uses: sliteteam/[email protected]
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY_PROD }}

- name: Build the docker image
run: |-
docker build \
--target production -t timetracker_ui -f Dockerfile_prod \
.

- name: Publish docker image to prod aws container registry
run: |
make login publish_prod image_tag=$RELEASE_VERSION

- name: SCP files via ssh key
uses: appleboy/scp-action@master
env:
USERNAME: ${{ secrets.AWS_EC2_USER }}
HOST: ${{ secrets.PROD_UI_URL }}
KEY: ${{ secrets.PROD_AWS_PRIVATE_KEY }}
with:
source: './infrastructure/aws_ec2.sh'
target: '.'

- name: SCP files via ssh key - .prod.aws.env
uses: appleboy/scp-action@master
env:
USERNAME: ${{ secrets.AWS_EC2_USER }}
HOST: ${{ secrets.PROD_UI_URL }}
KEY: ${{ secrets.PROD_AWS_PRIVATE_KEY }}
with:
source: '.prod.aws.env'
target: '.'

- name: Deploy
run: |
TEMP=$(mktemp)
echo "${{ secrets.PROD_AWS_PRIVATE_KEY }}" > $TEMP
chmod 400 $TEMP
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.PROD_UI_URL }} "chmod +x ./infrastructure/aws_ec2.sh"
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.PROD_UI_URL }} "./infrastructure/aws_ec2.sh $RELEASE_VERSION" prod
67 changes: 67 additions & 0 deletions .github/workflows/aws-ui-cd-stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: time-tracker-ui-cd-stage

on:
release:
types:
- published

jobs:
cd:
runs-on: ubuntu-latest
env:
TF_WORKSPACE: stage
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get the release_version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo $RELEASE_VERSION


- name: Unlock STAGE secrets
uses: sliteteam/[email protected]
env:
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY_STAGE }}

- name: Build the docker image
run: |-
docker build \
--target production -t timetracker_ui -f Dockerfile_stage \
.

- name: Publish docker image to stage AWS container registry
run: |
make login publish image_tag=$RELEASE_VERSION

- name: SCP files via ssh key - script
uses: appleboy/scp-action@master
env:
USERNAME: ${{ secrets.AWS_EC2_USER }}
HOST: ${{ secrets.STAGE_UI_URL }}
KEY: ${{ secrets.STAGE_AWS_PRIVATE_KEY }}
with:
source: './infrastructure/aws_ec2.sh'
target: '.'

- name: SCP files via ssh key - .stage.aws.env
uses: appleboy/scp-action@master
env:
USERNAME: ${{ secrets.AWS_EC2_USER }}
HOST: ${{ secrets.STAGE_UI_URL }}
KEY: ${{ secrets.STAGE_AWS_PRIVATE_KEY }}
with:
source: '.stage.aws.env'
target: '.'

- name: Deploy
run: |
TEMP=$(mktemp)
echo "${{ secrets.STAGE_AWS_PRIVATE_KEY }}" > $TEMP
chmod 400 $TEMP
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.STAGE_UI_URL }} "chmod +x ./infrastructure/aws_ec2.sh"
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.STAGE_UI_URL }} "./infrastructure/aws_ec2.sh $RELEASE_VERSION" stage
4 changes: 1 addition & 3 deletions .github/workflows/time-tracker-ui-cd-prod.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: time-tracker-ui-cd-prod

on:
release:
types:
- published
workflow_dispatch # deactivate workflow and run it manually only

jobs:
cd:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/time-tracker-ui-cd-stage.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: time-tracker-ui-cd-stage

on:
push:
tags:
- 'v*.*.*'
workflow_dispatch # deactivate workflow and run it manually only

jobs:
cd:
Expand Down
Binary file added .prod.aws.env
Binary file not shown.
Binary file modified .prod.env
Binary file not shown.
Binary file added .stage.aws.env
Binary file not shown.
Binary file modified .stage.env
Binary file not shown.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ testdev: ## Run all tests on docker container timetracker_ui at the Dev
docker exec timetracker_ui bash -c "npm run ci-test"

.PHONY: publish
publish: require-acr-arg require-image_tag-arg ## Upload a docker image to the stage azure container registry acr=<name_of_the_azure_container_registry> image_tag=<tag_for_the_image>
docker tag timetracker_ui:latest $(acr).azurecr.io/timetracker_ui:$(image_tag)
docker push $(acr).azurecr.io/timetracker_ui:$(image_tag)
publish: require-image_tag-arg ## Upload a docker image to the stage AWS container registry image_tag=<tag_for_the_image>
docker tag timetracker_ui:latest 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/stage-ui:$(image_tag)
docker push 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/stage-ui:$(image_tag)

.PHONY: build_prod
build_prod: ## Create docker image with dependencies needed for production -- to test locally only
Expand Down Expand Up @@ -80,13 +80,13 @@ remove_prod: ## Delete container timetracker_ui_prod.
docker rm timetracker_ui_prod

.PHONY: publish_prod
publish_prod: ## Upload a docker image to the prod azure container registry acr=<name_of_the_azure_container_registry> image_tag=<tag_for_the_image>
docker tag timetracker_ui_prod:latest $(acr).azurecr.io/timetracker_ui:$(image_tag)
docker push $(acr).azurecr.io/timetracker_ui:$(image_tag)
publish_prod: require-image_tag-arg ## Upload a docker image to the prod AWS container registry image_tag=<tag_for_the_image>
docker tag timetracker_ui:latest 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/prod-ui:$(image_tag)
docker push 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/prod-ui:$(image_tag)

.PHONY: login
login: ## Login in respository of docker images
az acr login --name $(acr)
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 568748651446.dkr.ecr.us-east-1.amazonaws.com

.PHONY: release
release: require-VERSION-arg require-COMMENT-arg ## Creates an pushes a new tag.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Stryker is also executed on GitHub actions with the following cron expresion:

Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).

## Deploy the app on Azure
## Deploy the app on Azure (deprecated)

The app deployment is automatically executed after each pull request is merged in master. That's wht it is necessary that each pull request meets at least 80% of test coverage.

Expand Down
6 changes: 6 additions & 0 deletions infrastructure/aws_ec2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/sh
echo "Deploying $1..."
docker ps -aq | xargs docker stop| xargs docker rm --force --volumes
docker system prune -af
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 568748651446.dkr.ecr.us-east-1.amazonaws.com
docker run -d --name timetracker_ui --env-file .$2.aws.env -p 80:80 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/$2-ui:$1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ProjectService {
}

getRecentProjects(): Observable<Project[]> {
return this.http.get<Project[]>(`${this.url}/recent`);
return this.http.get<Project[]>(`${this.url}/recent/`);
}

createProject(projectData): Observable<any> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class InjectTokenInterceptor implements HttpInterceptor {
const token = this.isProduction ? this.azureAdB2CService.getBearerToken() : this.loginService.getBearerToken();
const requestWithHeaders = request.clone(
{
headers: request.headers.set('Authorization',
headers: request.headers.set('token',
'Bearer ' + token)
});
return next.handle(requestWithHeaders)
Expand Down
14 changes: 7 additions & 7 deletions src/app/modules/time-clock/services/entry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ export class EntryService {
urlInProductionLegacy = environment.production === EnvironmentType.TT_PROD_LEGACY;

loadActiveEntry(): Observable<any> {
return this.http.get(`${this.baseUrl}/running`);
return this.http.get(`${this.baseUrl}/running/`);
}

loadEntries(date): Observable<any> {
const timezoneOffset = new Date().getTimezoneOffset();
return this.http.get(`${this.baseUrl}?month=${date.month}&year=${date.year}&timezone_offset=${timezoneOffset}`);
return this.http.get(`${this.baseUrl}/?month=${date.month}&year=${date.year}&timezone_offset=${timezoneOffset}`);
}

createEntry(entryData): Observable<any> {
return this.http.post(this.baseUrl, entryData);
return this.http.post(`${this.baseUrl}/`, entryData);
}

updateEntry(entryData): Observable<any> {
Expand All @@ -47,7 +47,7 @@ export class EntryService {

stopEntryRunning(idEntry: string): Observable<any> {
return (this.urlInProductionLegacy ?
this.http.post(`${this.baseUrl}/${idEntry}/stop`, null) : this.http.put(`${this.baseUrl}/stop`, null) );
this.http.post(`${this.baseUrl}/${idEntry}/stop/`, null) : this.http.put(`${this.baseUrl}/stop/`, null) );
}

restartEntry(idEntry: string): Observable<Entry> {
Expand All @@ -57,20 +57,20 @@ export class EntryService {

summary(): Observable<TimeEntriesSummary> {
const timeOffset = new Date().getTimezoneOffset();
const summaryUrl = `${this.baseUrl}/summary?time_offset=${timeOffset}`;
const summaryUrl = `${this.baseUrl}/summary/?time_offset=${timeOffset}`;
return this.http.get<TimeEntriesSummary>(summaryUrl);
}

findEntriesByProjectId(projectId: string): Observable<Entry[]> {
const startDate = this.getDateLastMonth();
const endDate = this.getCurrentDate();
const findEntriesByProjectURL = `${this.baseUrl}?limit=2&project_id=${projectId}&start_date=${startDate}&end_date=${endDate}`;
const findEntriesByProjectURL = `${this.baseUrl}/?limit=2&project_id=${projectId}&start_date=${startDate}&end_date=${endDate}`;
return this.http.get<Entry[]>(findEntriesByProjectURL);
}

loadEntriesByTimeRange(range: TimeEntriesTimeRange, userId: string): Observable<any> {
const MAX_NUMBER_OF_ENTRIES_FOR_REPORTS = 9999;
const loadEntriesByTimeRangeURL = this.urlInProductionLegacy ? this.baseUrl : this.baseUrl + '/report';
const loadEntriesByTimeRangeURL = this.urlInProductionLegacy ? this.baseUrl : this.baseUrl + '/report/';
return this.http.get(loadEntriesByTimeRangeURL,
{
params: {
Expand Down