-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (69 loc) · 2.51 KB
/
sorcery-vm-dev.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Sorcery VM DEV deployment
on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Publish
run: dotnet publish -c Debug -o ./dev
- name: Compress artifact
run: tar -czvf sorcery-dev.tar.gz -C ./dev .
- name: Upload artifact
uses: actions/[email protected]
with:
name: sorcery-dev
path: ./sorcery-dev.tar.gz
if-no-files-found: error
deploy:
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
needs: [publish]
steps:
- name: Download artifact
uses: actions/[email protected]
with:
name: sorcery-dev
path: ./
- name: Query public IP
id: ip
uses: haythem/[email protected]
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.SORCERY_AZURE_CREDENTIALS }}
- name: Azure CLI - allow connections from worker
id: jitAllow
uses: azure/CLI@v1
with:
azcliversion: 2.34.1
inlineScript: |
az network nsg rule create -g ${{ secrets.SORCERY_AZURE_RG_NAME }} --nsg-name ${{ secrets.SORCERY_AZURE_NSG_NAME }} -n GitHubActionDeployJIT --priority 100 \
--source-address-prefixes ${{ steps.ip.outputs.ipv4 }} --destination-port-ranges 22 --direction Inbound --access Allow --protocol TCP
- name: Install SSH key
uses: shimataro/[email protected]
with:
key: ${{ secrets.SORCERY_VM_KEY }}
known_hosts: ${{ secrets.SORCERY_VM_KNOWN_HOSTS }}
- name: scp to Sorcery-VM
run: scp ./sorcery-dev.tar.gz "${{ secrets.SORCERY_VM_USER }}@${{ secrets.SORCERY_VM_IP }}:/home/${{ secrets.SORCERY_VM_USER }}/server/dev"
- name: Restart nginx via SSH
run: ssh "${{ secrets.SORCERY_VM_USER }}@${{ secrets.SORCERY_VM_IP }}" \
"sudo rm -rf /usr/share/nginx/sorcery-dev/* && sudo tar -xzf /home/${{ secrets.SORCERY_VM_USER }}/server/dev/sorcery-dev.tar.gz -C /usr/share/nginx/sorcery-dev . && sudo nginx -s reload"
- name: Azure CLI - remove JIT rule
if: always()
uses: azure/CLI@v1
with:
azcliversion: 2.34.1
inlineScript: |
az network nsg rule delete -g ${{ secrets.SORCERY_AZURE_RG_NAME }} --nsg-name ${{ secrets.SORCERY_AZURE_NSG_NAME }} -n GitHubActionDeployJIT