diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index da7feae..0683a02 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,6 +38,19 @@ jobs: docker build -t huranit-server . docker tag huranit-server hysong4u/huranit-server:latest docker push hysong4u/huranit-server:latest + + - name: Get timestamp + uses: gerred/actions/current-time@master + id: current-time + + - name: Run string replace + uses: frabert/replace-string-action@master + id: format-time + with: + pattern: '[:\.]+' + string: "${{ steps.current-time.outputs.time }}" + replace-with: '-' + flags: 'g' - name: Deploy to EC2 env: @@ -50,6 +63,7 @@ jobs: docker pull hysong4u/huranit-server:latest existing_container_id=$(sudo docker ps -q --filter "publish=8081") [ -n "$existing_container_id" ] && sudo docker stop $existing_container_id && sudo docker rm $existing_container_id + sudo docker image prune -f docker run -d -p 8081:8081 hysong4u/huranit-server:latest EOF