-
Notifications
You must be signed in to change notification settings - Fork 627
/
docker-webapp-container-on-azure.yml
75 lines (69 loc) · 3.13 KB
/
docker-webapp-container-on-azure.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
name: Build and deploy Docker app to Azure
on: push
# CONFIGURATION
# For help, go to https://github.com/Azure/Actions
#
# Set up the following secrets in your repository:
# AZURE_CREDENTIALS, REGISTRY_USERNAME, REGISTRY_PASSWORD, REGISTRY_URL
# 2. Change these variables for your configuration:
env:
AZURE_WEBAPP_NAME: AppWithContainer # set this to your application's name
CONTAINER_REGISTRY: ${{ secrets.REGISTRY_URL }} # set secret with Container Registry URL, example : xyz.azurecr.io
# AZURE_RESOURCE_GROUP: ActionsDemo # set this to your Azure Resource group's name - Needed only if you are provisioning the app in the workflow
# AZURE_APP_PLAN: ActionPlan # set this to your App service plan's name - Needed only if you are provisioning the app in the workflow
jobs:
build-and-deploy-to-dev:
runs-on: ubuntu-latest
environment: dev
steps:
- uses: actions/checkout@v3
- name: Azure authentication
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# - name: Azure CLI script to provision a new Web App for Container
# uses: azure/CLI@v0-beta
# with:
# azcliversion: latest
# inlineScript: |
# az webapp create --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --plan ${{ env.AZURE_APP_PLAN }} --name ${{ env.AZURE_WEBAPP_NAME }} -i nginx
- name: ACR authentication
uses: azure/docker-login@v1
with:
login-server: ${{ env.CONTAINER_REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Docker Build & Push to ACR
run: |
docker build . -t ${{ env.CONTAINER_REGISTRY }}/nodejsapp:${{ github.sha }}
docker push ${{ env.CONTAINER_REGISTRY }}/nodejsapp:${{ github.sha }}
# Uncomment the below action snippet if the Web app credentials are not updated as web app settings
# - name: Set Web App ACR authentication
# uses: Azure/appservice-settings@v1
# with:
# app-name: ${{ env.AZURE_WEBAPP_NAME }}
# app-settings-json: |
# [
# {
# "name": "DOCKER_REGISTRY_SERVER_PASSWORD",
# "value": "${{ secrets.REGISTRY_PASSWORD }}",
# "slotSetting": false
# },
# {
# "name": "DOCKER_REGISTRY_SERVER_URL",
# "value": "https://${{ env.CONTAINER_REGISTRY }}",
# "slotSetting": false
# },
# {
# "name": "DOCKER_REGISTRY_SERVER_USERNAME",
# "value": "${{ secrets.REGISTRY_USERNAME }}",
# "slotSetting": false
# }
# ]
- name: 'Deploy to Azure Web App for Container'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
images: ${{ env.CONTAINER_REGISTRY }}/nodejsapp:${{ github.sha }}
# startup-command: 'npm start' # Include start up command to start the app container
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples