Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update github action #91

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 23 additions & 27 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:
run: |
docker buildx build --platform linux/amd64 -t sast/sast-link -f docker/Dockerfile --output type=docker,dest=image.tar .

- name: Deploy to Server
id: deploy
- name: Copy Docker image to server
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
Expand All @@ -40,32 +39,29 @@ jobs:
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: /tmp/image.tar
SCRIPT_AFTER: |
### Notice: run for develop ###
# Stop and remove existing container if it exists
if [ "$(docker ps -aq -f name=sastlink)" ]; then
docker stop sastlink
docker rm sastlink
fi
# Remove existing image if it exists
if [ "$(docker images -q sast/sast-link)" ]; then
docker rmi sast/sast-link
fi
# Load the new image and run it
docker load -i ~/image.tar
docker run -d --name sastlink -p 8080:8080 sast/sast-link
echo "---------"
echo $RSYNC_STDOUT
echo "---------"
RSYNC_STDOUT: ${{ env.RSYNC_STDOUT }}


- name: Check Deployment Status
run: |
if [[ "${{ steps.deploy.outputs.RSYNC_STDOUT }}" == *"error"* ]]; then
echo "Deployment failed"
exit 1
fi
- name: Deploy in server
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script_stop: true
script: |
### Notice: run for develop ###
# Stop and remove existing container if it exists
if [ "$(docker ps -aq -f name=sastlink)" ]; then
docker stop sastlink
docker rm sastlink
fi
# Remove existing image if it exists
if [ "$(docker images -q sast/sast-link)" ]; then
docker rmi sast/sast-link
fi
# Load the new image and run it
# It will failed, for test
docker load -i ~/image.tar
docker run -d --name sastlink -p 8080:8080 sast/sast-link

- name: Send Success Message
if: ${{ success() }}
Expand Down
Loading