@@ -51,47 +51,48 @@ jobs:
5151 docker push $(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7)
5252 docker push $(echo $REGISTRY)/$(echo $IMAGE_NAME):latest
5353
54- # deploy:
55- # runs-on: ubuntu-latest
56- # needs: build_and_push
54+ deploy :
55+ runs-on : ubuntu-latest
56+ needs : build_and_push
5757
58- # steps:
59- # - name: Checkout the repo
60- # uses: actions/checkout@v2
58+ steps :
59+ - name : Checkout the repo
60+ uses : actions/checkout@v2
6161
62- # - name: Copy docker-compose.yml to Droplet
63- # uses: appleboy/scp-action@master
64- # with:
65- # host: ${{ secrets.HOST }}
66- # username: ${{ secrets.USERNAME }}
67- # key: ${{ secrets.SSHKEY }}
68- # passphrase: ${{ secrets.PASSPHRASE }}
69- # source: "docker-compose.yml"
70- # target: "myapp"
62+ - name : Copy docker-compose.yml to Droplet
63+ uses : appleboy/scp-action@master
64+ with :
65+ host : ${{ secrets.HOST }}
66+ username : ${{ secrets.USERNAME }}
67+ key : ${{ secrets.SSHKEY }}
68+ passphrase : ${{ secrets.PASSPHRASE }}
69+ source : " docker-compose.yml"
70+ target : " myapp"
7171
72- # - name: Deploy to Digital Ocean droplet via SSH action
73- # uses: appleboy/ssh-action@master
74- # with:
75- # host: ${{ secrets.HOST }}
76- # username: ${{ secrets.USERNAME }}
77- # key: ${{ secrets.SSHKEY }}
78- # passphrase: ${{ secrets.PASSPHRASE }}
79- # script: |
80- # # Navigate to the app directory
81- # cd myapp
72+ - name : Deploy to Digital Ocean droplet via SSH action
73+ uses : appleboy/ssh-action@master
74+ with :
75+ host : ${{ secrets.HOST }}
76+ username : ${{ secrets.USERNAME }}
77+ key : ${{ secrets.SSHKEY }}
78+ passphrase : ${{ secrets.PASSPHRASE }}
79+ envs : IMAGE_NAME,REGISTRY,{{ secrets.DIGITALOCEAN_ACCESS_TOKEN }},GITHUB_SHA
80+ script : |
81+ # Navigate to the app directory
82+ cd myapp
8283
83- # # Create the .env file from the GitHub Secret
84- # echo "${{ secrets.ENV_FILE }}" > .env
84+ # Create the .env file from the GitHub Secret
85+ echo "${{ secrets.DOT_ENV_FILE }}" > .env
8586
86- # # Login to registry
87- # docker login -u ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} -p ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} registry.digitalocean.com
87+ # Login to registry
88+ docker login -u ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} -p ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} registry.digitalocean.com
8889
89- # # Update the image definition in docker-compose.yml to use the new tag
90- # # This makes sure we run the exact version we just built
91- # sed -i 's|image: .*|image: $(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7)|' docker-compose.yml
90+ # Update the image definition in docker-compose.yml to use the new tag
91+ # This makes sure we run the exact version we just built
92+ sed -i 's|image: .*|image: $(echo $REGISTRY)/$(echo $IMAGE_NAME):$(echo $GITHUB_SHA | head -c7)|' docker-compose.yml
9293
93- # # Pull the new backend image
94- # docker compose pull backend
94+ # Pull the new backend image
95+ docker compose pull backend
9596
96- # # Stop and recreate ONLY the backend service with the new image
97- # docker compose up -d --no-deps backend
97+ # Stop and recreate ONLY the backend service with the new image
98+ docker compose up -d --no-deps backend
0 commit comments