Skip to content

Commit

Permalink
cd: updated staging.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanky-23 authored Aug 15, 2024
1 parent 16761cf commit 269d45b
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
runs-on: bpstaging-runner
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -22,25 +22,21 @@ jobs:
SSH_USERNAME: ${{ secrets.USERNAME }}
SSH_PASSWORD: ${{ secrets.PASSWORD }}

- name: Build Docker images
- name: Pull from GitHub
id: pull
run: |
docker compose --env-file .env -f docker-compose.staging.yml build
remote_repo="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
# git remote add action $remote_repo
git clone $remote_repo staging
- name: List Docker images
run: docker images

- name: Save Docker images to tarball
run: |
docker save hng_boilerplate_expressjs-backend_staging:latest | gzip > staging-images.tar.gz
- name: Copy Docker images to server
- name: Sync with the server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
source: "staging-images.tar.gz"
target: "~/images-tar"
source: "staging/*"
target: "~/staging-deployment/hng_boilerplate_expressjs/"

- name: Deploy to server
uses: appleboy/ssh-action@master
Expand All @@ -53,6 +49,5 @@ jobs:
git stash
git checkout staging
git pull
docker load -i ~/images-tar/staging-images.tar.gz
docker compose -f docker-compose.staging.yml down
docker compose -f docker-compose.staging.yml up -d
npm install
pm2 restart all

0 comments on commit 269d45b

Please sign in to comment.