-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (56 loc) · 2.2 KB
/
docker-deploy.yaml
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
name: Build and Push Docker Image
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Log in to Docker Hub
run: |
docker login guildwarspartysearch.azurecr.io --username "${{ secrets.DOCKERHUB_USERNAME }}" --password "${{ secrets.DOCKERHUB_PASSWORD }}"
- name: Build and push Docker image
run: |
cd GuildWarsPartySearch
.\BuildDockerImage.ps1
docker push guildwarspartysearch.azurecr.io/guildwarspartysearch.server
shell: pwsh
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Login to Azure
shell: pwsh
run: |
az login --service-principal -u "${{ secrets.AZURE_CLIENTID }}" -p "${{ secrets.AZURE_SECRET }}" --tenant "${{ secrets.AZURE_TENANT }}"
- name: Check and Delete Existing Container Instance
shell: pwsh
run: |
# Check if the container instance exists
$exists = az container show --name guildwarspartysearch --resource-group ${{ secrets.AZURE_RESOURCEGROUPNAME }} --query "name" -o tsv
if ($exists -eq "guildwarspartysearch") {
Write-Host "Container instance exists. Deleting..."
# Delete the existing container instance
az container delete --name guildwarspartysearch --resource-group ${{ secrets.AZURE_RESOURCEGROUPNAME }} --yes
} else {
Write-Host "Container instance does not exist. Skipping delete step."
}
- name: Create New Container Instance
shell: pwsh
run: |
az container create `
--resource-group ${{ secrets.AZURE_RESOURCEGROUPNAME }} `
--name guildwarspartysearch `
--image guildwarspartysearch.azurecr.io/guildwarspartysearch.server:latest `
--cpu 1 --memory 1 `
--registry-login-server guildwarspartysearch.azurecr.io `
--registry-username ${{ secrets.DOCKERHUB_USERNAME }} `
--registry-password ${{ secrets.DOCKERHUB_PASSWORD }} `
--dns-name-label guildwarspartysearch `
--ports 8080