Skip to content

Commit

Permalink
env file handeling
Browse files Browse the repository at this point in the history
  • Loading branch information
p-shubh committed May 15, 2024
1 parent ff078d2 commit 8069db8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:
echo $TAG
export GITHUB_REF_IMAGE=ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA
export GITHUB_BRANCH_IMAGE=ghcr.io/$GITHUB_REPOSITORY:$TAG
export GITHUB_REF_IMAGE=$(echo $GITHUB_REF_IMAGE | tr '[:upper:]' '[:lower:]')
export GITHUB_BRANCH_IMAGE=$(echo $GITHUB_BRANCH_IMAGE | tr '[:upper:]' '[:lower:]')
# export GITHUB_REF_IMAGE=$(echo $GITHUB_REF_IMAGE | tr '[:upper:]' '[:lower:]')
# export GITHUB_BRANCH_IMAGE=$(echo $GITHUB_BRANCH_IMAGE | tr '[:upper:]' '[:lower:]')
docker build --build-arg version=$GITHUB_SHA -t $GITHUB_REF_IMAGE -t $GITHUB_BRANCH_IMAGE .
echo "Pushing Image to GitHub Container Registry"
echo "Pushing Frontend Image to GitHub Container Registry"
docker push $GITHUB_REF_IMAGE
docker push $GITHUB_BRANCH_IMAGE
rm -rf .env
Expand All @@ -64,8 +64,7 @@ jobs:
sudo podman stop sui_backend && sudo podman rm sui_backend && sudo podman image rm ghcr.io/p-shubh/sui_overflow_hack:main
echo ${{ secrets.GHCR_TOKEN }} | sudo podman login ghcr.io -u secrets.GHCR_USERNAME --password-stdin
sudo podman pull ghcr.io/p-shubh/sui_overflow_hack:main
sudo podman run --name="sui_backend" --env-file=.env -p 9079:8080 --net=bridge -d ghcr.io/p-shubh/sui_overflow_hack:main
sudo podman run --name="sui_backend" --env-file=.env -p 8181:6060 --net=bridge -d ghcr.io/p-shubh/sui_overflow_hack:main
- name: Deploy on Frontend server
if: github.ref == 'refs/heads/frontend'
uses: appleboy/[email protected]
Expand All @@ -76,7 +75,7 @@ jobs:
port: ${{ secrets.DEV_SSH_PORT }}
script: |
pwd
# docker stop sui_frontend || true && docker image rm ghcr.io/p-shubh/sui_overflow_hack:frontend
echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
docker pull ghcr.io/p-shubh/sui_overflow_hack:frontend
docker run --name="sui-frontend" --rm -p 8181:6060 --net=bridge -d ghcr.io/p-shubh/sui_overflow_hack:frontend
sudo podman stop sui-frontend || true && sudo podman image rm ghcr.io/p-shubh/sui_overflow_hack:frontend
echo ${{ secrets.GHCR_TOKEN }} | sudo podman login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
sudo podman pull ghcr.io/p-shubh/sui_overflow_hack:frontend
sudo podman run --name="sui-frontend" --rm -p 4040:6060 --net=bridge -d ghcr.io/p-shubh/sui_overflow_hack:frontend
15 changes: 11 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ package main

import (
router "hack/Router"
"log"
"os"

"github.com/joho/godotenv"
)

func main() {
// err := godotenv.Load()
// if err != nil {
// log.Fatal("Error loading .env file")
// }
if os.Getenv("LOAD_CONFIG_FILE") == "" {
// Load environment variables from .env file
err := godotenv.Load()
if err != nil {
log.Printf("Error in reading the config file : %v\n", err)
}
}
router.HandleRequest()
}

0 comments on commit 8069db8

Please sign in to comment.