File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343 docker push $REGISTRY/$IMAGE_NAME:latest
4444 docker push $REGISTRY/$IMAGE_NAME:${{ github.sha }}
4545
46- # ---------- DEPLOY ----------
46+ # ---------- DEPLOY ----------
4747 - name : Setup SSH
4848 run : |
4949 set -x
@@ -54,15 +54,25 @@ jobs:
5454 echo "Scanning SSH host key..."
5555 ssh-keyscan -T 5 -H ${{ secrets.DO_HOST }} >> ~/.ssh/known_hosts || \
5656 echo "ssh-keyscan failed, continuing anyway"
57-
57+
5858 - name : Deploy
5959 run : |
60- IMAGE="ghcr.io/aavtic/fops:latest"
60+ # Construct the full image URL using the workflow env vars
61+ # This ensures you are pulling exactly what you just built
62+ IMAGE="$REGISTRY/$IMAGE_NAME:latest"
6163 CONTAINER="app"
6264
63- # Updated to use secrets for User and Host
65+ echo "Deploying $IMAGE to remote server..."
66+
67+ # The variables $IMAGE and $CONTAINER are expanded locally
68+ # before being sent to the remote server because we didn't quote 'EOF'
6469 ssh ${{ secrets.DO_USER }}@${{ secrets.DO_HOST }} << EOF
65- docker pull ${IMAGE}
66- docker rm -f ${CONTAINER} || true
67- docker run -d --name ${CONTAINER} ${IMAGE}
70+ set -e
71+
72+ # Optional: If the package is Private, you must docker login here first
73+ # echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
74+
75+ docker pull $IMAGE
76+ docker rm -f $CONTAINER || true
77+ docker run -d --name $CONTAINER $IMAGE
6878 EOF
You can’t perform that action at this time.
0 commit comments