Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:mbuchoff/hackathon_backend_23090…
Browse files Browse the repository at this point in the history
…9 into develop
  • Loading branch information
arferreira committed Sep 9, 2023
2 parents 2b4797f + 115fd3e commit 4188423
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
API_KEY=
CORS_ALLOWED_ORIGINS=
ENV=
30 changes: 30 additions & 0 deletions .github/workflows/azure_webapp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Azure Webapp deploy

on:
pull_request:
branches:
- develop
push:
branches:
- develop

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: azure/docker-login@v1
with:
# login-server: mycontainer.azurecr.io
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t mbuchoff/hackathon_230909:${{ github.sha }}
docker push mbuchoff/hackathon_230909:${{ github.sha }}
- uses: azure/webapps-deploy@v2
with:
app-name: 'app-hackathon'
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
images: 'mbuchoff/hackathon_230909:${{ github.sha }}'
11 changes: 1 addition & 10 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
name: Build, Test and Deploy backend

on:
# opening a pull request to master and develop branch will be a trigger
pull_request:
branches:
- develop
# any code pushed to master and develop branch will also be a trigger
push:
branches:
- develop
on: workflow_dispatch

jobs:
build-test:
Expand Down Expand Up @@ -40,5 +32,4 @@ jobs:
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
cd ~/.scripts
./docker-ec2-deploy.sh
9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ version: "3"

services:
hackathon-api-go:
build:
context: .
dockerfile: Dockerfile
container_name: hackathon-api-go
build: .
restart: always
# env_file: .env
ports:
- "9999:9999"
volumes:
- .:/app
37 changes: 37 additions & 0 deletions docker-ec2-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

TARGET='develop'

cd ~/api || exit

ACTION_COLOR='\033[1;90m'
NO_COLOR='\033[0m'

echo -e ${ACTION_COLOR} Checking if we are on the target branch
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" != ${TARGET} ]
then
exit 0
fi

# Checking if the repository is up to date.

git fetch
HEAD_HASH=$(git rev-parse HEAD)
UPSTREAM_HASH=$(git rev-parse ${TARGET}@{upstream})

if [ "$HEAD_HASH" == "$UPSTREAM_HASH" ]
then
echo -e "${FINISHED}"The current branch is up to date with origin/${TARGET}."${NO_COLOR}"
exit 0
fi

# If there are new changes, we pull these changes.

git pull origin develop;

# We can now build and start the containers

docker compose up -d --build

exit 0;

0 comments on commit 4188423

Please sign in to comment.