-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/fix-authentication
- Loading branch information
Showing
17 changed files
with
276 additions
and
118 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Build and Upload | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build Docker image | ||
run: docker build -t hngdevops/nextjs-boilerplate:dev -f docker/development/Dockerfile . | ||
|
||
- name: Save and compress Docker image | ||
run: | | ||
docker save hngdevops/nextjs-boilerplate:dev > nextjs-dev.tar | ||
gzip nextjs-dev.tar | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: docker-image | ||
path: nextjs-dev.tar.gz | ||
|
||
copy-and-load-image: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: github.event.repository.fork == false | ||
|
||
environment: | ||
name: "dev" | ||
url: ${{ vars.URL }} | ||
|
||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: docker-image | ||
path: . | ||
|
||
- name: Copy to server | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
source: "nextjs-dev.tar.gz" | ||
target: "/tmp/nextjs" | ||
|
||
- name: Load image in server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd /tmp/nextjs | ||
gunzip nextjs-dev.tar.gz | ||
docker load < nextjs-dev.tar | ||
rm -f nextjs-dev.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,47 +9,60 @@ on: | |
- .github/workflows/** | ||
|
||
jobs: | ||
build_and_push: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build Docker image | ||
run: docker build -t hngdevops/nextjs-boilerplate:prod -f docker/prod/Dockerfile . | ||
|
||
- name: Save and compress Docker image | ||
run: | | ||
docker save hngdevops/nextjs-boilerplate:prod > nextjs-prod.tar | ||
gzip nextjs-prod.tar | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
file: docker/prod/Dockerfile | ||
push: true | ||
tags: hngdevops/nextjs-boilerplate:prod | ||
|
||
deploy_to_production: | ||
needs: build_and_push | ||
name: docker-image | ||
path: nextjs-prod.tar.gz | ||
|
||
deploy_to_prod: | ||
if: github.event.repository.fork == false | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: "production" | ||
name: "prod" | ||
url: ${{ vars.URL }} | ||
|
||
steps: | ||
- name: Deploy to production environment | ||
uses: appleboy/[email protected] | ||
- name: Download artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: docker-image | ||
path: . | ||
|
||
- name: Copy to server | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
source: "nextjs-prod.tar.gz" | ||
target: "/tmp/nextjs" | ||
|
||
- name: Deploy on server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd hng_boilerplate_nextjs | ||
./scripts/prod_deploy.sh | ||
cd /tmp/nextjs | ||
gunzip nextjs-prod.tar.gz | ||
docker load < nextjs-prod.tar | ||
rm -f nextjs-prod.tar | ||
cd /home/${{ secrets.USERNAME }}/hng_boilerplate_nextjs | ||
chmod +x ./scripts/*.sh | ||
./scripts/prod_deploy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,33 +9,26 @@ on: | |
- .github/workflows/** | ||
|
||
jobs: | ||
build_and_push: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build Docker image | ||
run: docker build -t hngdevops/nextjs-boilerplate:staging -f docker/staging/Dockerfile . | ||
|
||
- name: Save and compress Docker image | ||
run: | | ||
docker save hngdevops/nextjs-boilerplate:staging > nextjs-staging.tar | ||
gzip nextjs-staging.tar | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
file: docker/staging/Dockerfile | ||
push: true | ||
tags: hngdevops/nextjs-boilerplate:staging | ||
|
||
name: docker-image | ||
path: nextjs-staging.tar.gz | ||
|
||
deploy_to_staging: | ||
needs: build_and_push | ||
if: github.event.repository.fork == false | ||
runs-on: ubuntu-latest | ||
|
||
|
@@ -44,12 +37,32 @@ jobs: | |
url: ${{ vars.URL }} | ||
|
||
steps: | ||
- name: Deploy to staging environment | ||
uses: appleboy/[email protected] | ||
- name: Download artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: docker-image | ||
path: . | ||
|
||
- name: Copy to server | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
source: "nextjs-staging.tar.gz" | ||
target: "/tmp/nextjs" | ||
|
||
- name: Deploy on server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd hng_boilerplate_nextjs | ||
./scripts/staging_deploy.sh | ||
cd /tmp/nextjs | ||
gunzip nextjs-staging.tar.gz | ||
docker load < nextjs-staging.tar | ||
rm -f nextjs-staging.tar | ||
cd /home/${{ secrets.USERNAME }}/hng_boilerplate_nextjs | ||
chmod +x ./scripts/*.sh | ||
./scripts/staging_deploy.sh |
Oops, something went wrong.