-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #978 from hngprojects/Ravencodess-patch-1
Ravencodess patch 1
- Loading branch information
Showing
2 changed files
with
83 additions
and
34 deletions.
There are no files selected for viewing
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,49 @@ | ||
name: Anchor Deployment | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Build and Upload"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
deploy_to_dev: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: "anchor-java" | ||
url: ${{ vars.URL }} | ||
|
||
steps: | ||
- name: Download build artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
name: boilerplate-build | ||
path: boilerplate.tar.gz | ||
|
||
- name: Decode and create .env file | ||
run: | | ||
echo ${{ secrets.ENV }} | base64 -d > .env.java | ||
- name: Copy Artifacts to server | ||
run: | | ||
sudo apt update && sudo apt install sshpass -y | ||
sshpass -p ${{ secrets.PASSWORD }} scp -o StrictHostKeyChecking=no boilerplate.tar.gz .env.java ${{ secrets.USERNAME }}@${{ secrets.HOST }}:/tmp/ | ||
rm -f boilerplate.tar.gz .env | ||
- name: Deploy on server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
script: | | ||
cd boilerplate | ||
rm -rf * | ||
tar -xzf /tmp/boilerplate.tar.gz | ||
mv /tmp/.env.java .env | ||
rm -f /tmp/boilerplate.tar.gz | ||
cp -r .next/standalone/* . |
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 |
---|---|---|
|
@@ -10,38 +10,38 @@ jobs: | |
runs-on: ubuntu-latest | ||
if: github.event.repository.fork == false | ||
|
||
environment: | ||
name: "dev" | ||
url: ${{ vars.URL }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- 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: 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 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Cache pnpm modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.pnpm-store | ||
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm- | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build Next.js application | ||
run: pnpm build | ||
|
||
- name: Archive production artifacts | ||
run: tar -czf boilerplate.tar.gz .next public | ||
|
||
- name: Upload production artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: boilerplate-build | ||
path: boilerplate.tar.gz |