[CD][Hai] relocate script into bash file #21
Workflow file for this run
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: Publish docker images | |
on: | |
push: | |
tags: [ "v*" ] | |
env: | |
IMAGE_NAME: ${{ secrets.REGISTRY }}/swd392-domus/domus-api | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version-without-v }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 7.0.x | |
- name: Encrypt Production appsettings | |
run: gpg --quiet --batch --yes --decrypt --passphrase ${{ secrets.GPG_PASS_PHRASE }} --output Domus.Api/appsettings.Production.json Domus.Api/appsettings.Production.json.gpg | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build projects | |
run: dotnet build -c Release | |
- name: Get version | |
id: version | |
uses: battila7/get-version-action@v2 | |
- name: Build docker images | |
run: docker build -f Domus.Api/Dockerfile -t ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version-without-v }} . | |
- name: Authenticate | |
run: echo ${{ secrets.AUTH_TOKEN }} | docker login ${{ secrets.REGISTRY }} -u swd392-domus --password-stdin | |
- name: Publish images | |
run: docker push ${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version-without-v }} | |
deploy: | |
needs: publish | |
runs-on: self-hosted | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Configure SSH Key | |
run: | | |
mkdir -p $HOME/.ssh | |
touch $HOME/.ssh/azure_vm_key | |
echo "${{ secrets.AZURE_SSH_KEY }}" > $HOME/.ssh/azure_vm_key | |
chmod 600 $HOME/.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' < ./deploy_script.sh |