Skip to content

Commit

Permalink
Merge pull request #54 from Giveth/staging
Browse files Browse the repository at this point in the history
Fixing the Deployment CI Pipeline
  • Loading branch information
mhmdksh authored May 24, 2024
2 parents 676d34b + 19d6ab4 commit 9956a04
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,44 @@ jobs:
tag_with_ref: true
# Add commit hash to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha}
tag_with_sha: true

deploy:
if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master'
needs: publish
runs-on: ubuntu-latest
steps:
- name: production deploy
if: github.ref == 'refs/heads/master'
uses: garygrossgarten/github-action[email protected]
uses: appleboy/ssh-action@v1.0.3
with:
# pull images, restart docker, then remove unused docker images
command: cd givback-calculation && git checkout master && git pull origin master && docker-compose -f docker-compose-production.yml pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune -a --force
host: ${{ secrets.DEVELOP_HOST }}
username: ${{ secrets.DEVELOP_USERNAME }}
# passphrase: ${{ secrets.PASSPHRASE }}
privateKey: ${{ secrets.DEVELOP_PRIVATE_KEY}}
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USERNAME }}
key: ${{ secrets.PROD_PRIVATE_KEY }}
port: 22
script: |
cd $HOME/givback-calculation-production
git checkout master
git checkout -- .
git pull
docker compose -f docker-compose-production.yml pull
docker compose -f docker-compose-production.yml down
docker compose -f docker-compose-production.yml up -d
docker image prune -a --force
- name: staging deploy
if: github.ref == 'refs/heads/staging'
uses: garygrossgarten/github-action[email protected]
uses: appleboy/ssh-action@v1.0.3
with:
# pull images, restart docker, then remove unused docker images
command: cd givback-calculation-staging && git checkout staging && git pull origin staging && docker-compose -f docker-compose-staging.yml pull && docker-compose -f docker-compose-staging.yml down && docker-compose -f docker-compose-staging.yml up -d && docker image prune -a --force
host: ${{ secrets.DEVELOP_HOST }}
username: ${{ secrets.DEVELOP_USERNAME }}
# passphrase: ${{ secrets.PASSPHRASE }}
privateKey: ${{ secrets.DEVELOP_PRIVATE_KEY}}
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_PRIVATE_KEY }}
port: 22
script: |
cd $HOME/givback-calculation-staging
git checkout staging
git checkout -- .
git pull
docker compose -f docker-compose-staging.yml pull
docker compose -f docker-compose-staging.yml down
docker compose -f docker-compose-staging.yml up -d
docker image prune -a --force

0 comments on commit 9956a04

Please sign in to comment.