[CD][Hai] redefine the path to ssh #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Azure | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
if: success() | |
steps: | |
- name: Set Docker Tag | |
id: set-docket-tag | |
run: echo "::set-output name=tag::$(some-script-to-get-tag)" | |
- name: Configure SSH Key | |
run: | | |
if [ ! -d $HOME/.ssh ]; then | |
mkdir $HOME/.ssh | |
fi | |
echo "${{ secrets.AZURE_SSH_KEY }}" | base64 -d > $HOME/.ssh/azure_vm_key | |
chmod 600 ~/.ssh/azure_vm_key | |
- name: Deploy to Azure VM | |
run: | | |
ssh -i ~/.ssh/azure_vm_key \ | |
-o StrictHostKeyChecking=no \ | |
${{ secrets.AZURE_VM_USERNAME }}@${{ secrets.AZURE_VM_IP_ADDRESS }} \ | |
'bash -s' <<EOF | |
docker ps -q | xargs -r docker stop | |
docker container prune -f | |
docker run -d -p 443:80 ghcr.io/swd392-domus/domus-api:${{ steps.set-docker-tag.outputs.tag }} | |
EOF |