Skip to content

Commit

Permalink
Merge pull request #40 from erland-syafiq/fixing-deployment
Browse files Browse the repository at this point in the history
Added environment variables at build time
  • Loading branch information
erland-syafiq authored Jun 21, 2024
2 parents e078165 + aa5c64d commit fbb3721
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Production
name: Deploy site to production
on:
push:
branches: [main]
Expand All @@ -12,8 +12,14 @@ jobs:
uses: actions/checkout@v2
- name: Login to docker hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Clean earlier environment variables
run: rm site/.env.production || true
- name: Create environment variables
run: echo ${{ secrets.ENV_FILE }} > site/.env.production
- name: Build docker image
run: docker build -t vtmunc/site ./site
- name: Remove environment variables file
run: rm site/.env.production || true
- name: Publish images to docker hub
run: docker push vtmunc/site:latest

Expand All @@ -28,13 +34,7 @@ jobs:
run: docker pull vtmunc/site:latest
- name: Remove old containers
run: docker rm -f vtmunc || true
- name: Clean earlier .env
run: rm .env || true
- name: Create environment variables
run: echo ${{ secrets.ENV_FILE }} > .env
- name: Run container
run: docker run -p 3000:3000 -d --name vtmunc --env-file .env vtmunc/site
- name: Removing environment variabe
run: rm .env || true
- name: Clean up (Removes old containers)
run: docker run -p 3000:3000 -d --name vtmunc vtmunc/site
- name: Clean up (Removes old images)
run: docker system prune -f
5 changes: 3 additions & 2 deletions site/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
**/.vscode
**/npm-debug.log
**/coverage
**/.env
**/.editorconfig
**/.aws
**/.next
**/.next
**/.env
**/.env.development
4 changes: 2 additions & 2 deletions site/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

# .env
.env
# Environment variables
.env*

0 comments on commit fbb3721

Please sign in to comment.