diff --git a/.github/workflows/CI-CD.yml b/.github/workflows/CI-CD.yml index a1f9842..4b2672d 100644 --- a/.github/workflows/CI-CD.yml +++ b/.github/workflows/CI-CD.yml @@ -21,6 +21,7 @@ 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 @@ -28,22 +29,36 @@ jobs: steps: - name: production deploy if: github.ref == 'refs/heads/master' - uses: garygrossgarten/github-action-ssh@v0.6.4 + 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-ssh@v0.6.4 + 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