forked from CodeYourFuture/Full-Stack-Project-Assessment
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: shadi fakhri <[email protected]>
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 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,44 @@ | ||
name: Node.js CI/CD | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
|
||
jobs: | ||
build: | ||
runs-on: self-hosted | ||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Server Dependencies | ||
id: install-dependencies | ||
run: npm ci | ||
working-directory: ./server | ||
continue-on-error: false | ||
|
||
- name: Create .env File | ||
id: create-env-file | ||
run: | | ||
touch ./server/.env | ||
echo "EC2_HOST=${{ secrets.EC2_HOST }}" >> ./server/.env | ||
echo "EC2_SSH_KEY=${{ secrets.EC2_SSH_KEY }}" >> ./server/.env | ||
echo "EC2_USERNAME=${{ secrets.EC2_USERNAME }}" >> ./server/.env | ||
continue-on-error: false | ||
- name: Run Tests | ||
run: echo "No tests are available for this project." | ||
|
||
- name: Start Server/Run Application | ||
id: start-server | ||
run: pm2 restart BackendAPI | ||
working-directory: ./server | ||
continue-on-error: false | ||
|
||
- name: Handle Errors | ||
if: steps.install-dependencies.outcome != 'success' || steps.create-env-file.outcome != 'success' || steps.start-server.outcome != 'success' | ||
run: echo "::set-output name=workflow-error::true" |