fix: buh
This commit is contained in:
94
action.yml
94
action.yml
@@ -28,55 +28,55 @@ runs:
|
|||||||
REMOTE_USER: ${{ inputs.remote_user || 'ubuntu' }}
|
REMOTE_USER: ${{ inputs.remote_user || 'ubuntu' }}
|
||||||
DOCKER_COMPOSE_PATH: ${{ inputs.docker_compose_path }}
|
DOCKER_COMPOSE_PATH: ${{ inputs.docker_compose_path }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up SSH agent (to use private key)
|
- name: Set up SSH agent (to use private key)
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
chmod 600 ~/.ssh/id_rsa
|
chmod 600 ~/.ssh/id_rsa
|
||||||
# Optional: add known hosts
|
# Optional: add known hosts
|
||||||
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
||||||
chmod 644 ~/.ssh/known_hosts
|
chmod 644 ~/.ssh/known_hosts
|
||||||
# Ensure SSH config
|
# Ensure SSH config
|
||||||
echo "Host ${REMOTE_HOST}" >> ~/.ssh/config
|
echo "Host ${REMOTE_HOST}" >> ~/.ssh/config
|
||||||
echo " HostName ${REMOTE_HOST}" >> ~/.ssh/config
|
echo " HostName ${REMOTE_HOST}" >> ~/.ssh/config
|
||||||
echo " User ${REMOTE_USER}" >> ~/.ssh/config
|
echo " User ${REMOTE_USER}" >> ~/.ssh/config
|
||||||
echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
|
echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config
|
||||||
echo " StrictHostKeyChecking yes" >> ~/.ssh/config
|
echo " StrictHostKeyChecking yes" >> ~/.ssh/config
|
||||||
echo " UserKnownHostsFile ~/.ssh/known_hosts" >> ~/.ssh/config
|
echo " UserKnownHostsFile ~/.ssh/known_hosts" >> ~/.ssh/config
|
||||||
|
|
||||||
- name: Copy docker-compose.yml to remote host
|
- name: Copy docker-compose.yml to remote host
|
||||||
run: |
|
run: |
|
||||||
# Ensure the remote path exists
|
# Ensure the remote path exists
|
||||||
mkdir -p "$(dirname "${DEPLOYMENT_PATH}")"
|
mkdir -p "$(dirname "${DEPLOYMENT_PATH}")"
|
||||||
# Use scp to copy the file
|
# Use scp to copy the file
|
||||||
scp -o StrictHostKeyChecking=yes -o UserKnownHostsFile= ~/.ssh/known_hosts \
|
scp -o StrictHostKeyChecking=yes -o UserKnownHostsFile= ~/.ssh/known_hosts \
|
||||||
-i ~/.ssh/id_rsa \
|
-i ~/.ssh/id_rsa \
|
||||||
${COMPOSE_PATH} \
|
${COMPOSE_PATH} \
|
||||||
${REMOTE_USER}@${REMOTE_HOST}:"${DEPLOYMENT_PATH}"
|
${REMOTE_USER}@${REMOTE_HOST}:"${DEPLOYMENT_PATH}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Deploy services via SSH
|
- name: Deploy services via SSH
|
||||||
run: |
|
run: |
|
||||||
# Run docker-compose up -d on the remote host
|
# Run docker-compose up -d on the remote host
|
||||||
ssh -o StrictHostKeyChecking=yes \
|
ssh -o StrictHostKeyChecking=yes \
|
||||||
-o UserKnownHostsFile= ~/.ssh/known_hosts \
|
-o UserKnownHostsFile= ~/.ssh/known_hosts \
|
||||||
-i ~/.ssh/id_rsa \
|
-i ~/.ssh/id_rsa \
|
||||||
${REMOTE_USER}@${REMOTE_HOST} \
|
${REMOTE_USER}@${REMOTE_HOST} \
|
||||||
"docker-compose -f ${DEPLOYMENT_PATH} up -d --timeout 300"
|
"docker-compose -f ${DEPLOYMENT_PATH} up -d --timeout 300"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Verify services are running
|
- name: Verify services are running
|
||||||
run: |
|
run: |
|
||||||
ssh -o StrictHostKeyChecking=yes \
|
ssh -o StrictHostKeyChecking=yes \
|
||||||
-o UserKnownHostsFile= ~/.ssh/known_hosts \
|
-o UserKnownHostsFile= ~/.ssh/known_hosts \
|
||||||
-i ~/.ssh/id_rsa \
|
-i ~/.ssh/id_rsa \
|
||||||
${REMOTE_USER}@${REMOTE_HOST} \
|
${REMOTE_USER}@${REMOTE_HOST} \
|
||||||
"docker-compose -f ${DEPLOYMENT_PATH} ps"
|
"docker-compose -f ${DEPLOYMENT_PATH} ps"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Final success message
|
- name: Final success message
|
||||||
run: echo "✅ Docker Compose deployed successfully on ${REMOTE_HOST}"
|
run: echo "✅ Docker Compose deployed successfully on ${REMOTE_HOST}"
|
||||||
|
|||||||
Reference in New Issue
Block a user