Skip to content

Commit

Permalink
update action
Browse files Browse the repository at this point in the history
  • Loading branch information
Wcc723 committed Oct 4, 2023
1 parent ed34755 commit 5cafd58
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/deploy-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
jobs:
build-and-push:
runs-on: ubuntu-latest
env:
VARIABLE: ${{ secrets.ENV_VARIABLE }}
MONGO_ROOT_USERNAME: ${{ secrets.MONGO_ROOT_USERNAME }}
MONGO_ROOT_PASSWORD: ${{ secrets.MONGO_ROOT_PASSWORD }}

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -39,9 +34,20 @@ jobs:
run: |
mkdir -p ~/.ssh
ssh-keyscan ${{secrets.HOST_NAME}} >> ~/.ssh/known_hosts
- name: Create and transfer .env file to remote server
run: |
echo "Creating .env file"
echo MONGO_ROOT_USERNAME=${{ env.MONGO_ROOT_USERNAME }} > .env
echo MONGO_ROOT_PASSWORD=${{ env.MONGO_ROOT_PASSWORD }} >> .env
echo VARIABLE=${{ env.VARIABLE }} >> .env
echo "Transferring .env file to remote server"
scp .env root@${{ secrets.HOST_NAME }}:/root/.env
- name: Copy docker-compose.yml to remote server
run: |
scp ./docker-compose.yml root@${{secrets.HOST_NAME}}:/root/docker-compose.yml
ssh root@${{ secrets.HOST_NAME }} "docker-compose --env-file /root/.env -f /root/docker-compose.yml up -d"
- name: Deploy with Docker Compose
run: |
ssh root@${{secrets.HOST_NAME}} "docker-compose -f /root/docker-compose.yml up -d"

0 comments on commit 5cafd58

Please sign in to comment.