Commit fa027fa1 by Arjun Jhukal

removed the server depencency installation from the pipeline

parent 0cb315c6
...@@ -19,6 +19,18 @@ jobs: ...@@ -19,6 +19,18 @@ jobs:
node-version: 20 node-version: 20
cache: "npm" cache: "npm"
- name: Cache node modules
uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
${{ runner.os }}-nextjs-
- name: Install dependencies - name: Install dependencies
run: npm ci --prefer-offline --no-audit run: npm ci --prefer-offline --no-audit
...@@ -42,23 +54,124 @@ jobs: ...@@ -42,23 +54,124 @@ jobs:
- name: Deploy build to server - name: Deploy build to server
run: | run: |
rsync -az --delete \ rsync -avz --delete \
--exclude '.git' \ --exclude '.git' \
--exclude '.env*' \ --exclude '.env*' \
--exclude 'node_modules' \ --exclude 'node_modules' \
./ \ ./ \
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/var/www/getFirekirin/ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/var/www/getFirekirin/
- name: Install production dependencies & restart app - name: Restart application
run: | run: |
ssh -o ServerAliveInterval=60 \ ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF'
-o ServerAliveCountMax=3 \
-o StrictHostKeyChecking=no \
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF'
set -e
export CI=true
cd /var/www/getFirekirin cd /var/www/getFirekirin
npm ci --omit=dev --prefer-offline
pm2 reload ecosystem.config.js --update-env --env production || \ pm2 reload ecosystem.config.js --update-env --env production || \
pm2 start ecosystem.config.js --env production pm2 start ecosystem.config.js --env production
EOF EOF
- name: Notify Slack on Success
if: success()
uses: slackapi/slack-github-action@v1.27.0
with:
payload: |
{
"text": "✅ getFirekirin Deployment Successful!",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "✅ getFirekirin Deployment Successful"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Repository:*\n${{ github.repository }}"
},
{
"type": "mrkdwn",
"text": "*Branch:*\n${{ github.ref_name }}"
},
{
"type": "mrkdwn",
"text": "*Commit:*\n<${{ github.event.head_commit.url }}|${{ github.sha }}>"
},
{
"type": "mrkdwn",
"text": "*Author:*\n${{ github.actor }}"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Message:* ${{ github.event.head_commit.message }}"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Deployed to production at <!date^${{ github.event.head_commit.timestamp }}^{date_num} {time_secs}|${{ github.event.head_commit.timestamp }}>"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: Notify Slack on Failure
if: failure()
uses: slackapi/slack-github-action@v1.27.0
with:
payload: |
{
"text": "❌ getFirekirin Deployment Failed!",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "❌ getFirekirin Deployment Failed"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Repository:*\n${{ github.repository }}"
},
{
"type": "mrkdwn",
"text": "*Branch:*\n${{ github.ref_name }}"
},
{
"type": "mrkdwn",
"text": "*Commit:*\n<${{ github.event.head_commit.url }}|${{ github.sha }}>"
},
{
"type": "mrkdwn",
"text": "*Author:*\n${{ github.actor }}"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Action:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow Run>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment