Skip to content

Commit 44dd070

Browse files
authored
Create azure-container-webapp.yml
1 parent 6163355 commit 44dd070

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# This workflow will build and push a Docker container to an Azure Web App when a commit is pushed to your default branch.
2+
#
3+
# This workflow assumes you have already created the target Azure App Service web app.
4+
# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-custom-container?tabs=dotnet&pivots=container-linux
5+
#
6+
# To configure this workflow:
7+
#
8+
# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal.
9+
# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials
10+
#
11+
# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret.
12+
# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret
13+
#
14+
# 3. Create a GitHub Personal access token with "repo" and "read:packages" permissions.
15+
#
16+
# 4. Create three app settings on your Azure Web app:
17+
# DOCKER_REGISTRY_SERVER_URL: Set this to "https://ghcr.io"
18+
# DOCKER_REGISTRY_SERVER_USERNAME: Set this to the GitHub username or organization that owns the repository
19+
# DOCKER_REGISTRY_SERVER_PASSWORD: Set this to the value of your PAT token from the previous step
20+
#
21+
#
22+
# 5. Change the value for the AZURE_WEBAPP_NAME.
23+
#
24+
# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions
25+
# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
26+
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples
27+
28+
name: Build and deploy a container to an Azure Web App
29+
30+
env:
31+
AZURE_WEBAPP_NAME: frontend-erik # set this to the name of your Azure Web App
32+
33+
on:
34+
push:
35+
branches: [ "main" ]
36+
workflow_dispatch:
37+
38+
permissions:
39+
contents: read
40+
41+
jobs:
42+
build:
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
50+
51+
- name: Log in to GitHub container registry
52+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
53+
with:
54+
registry: ghcr.io
55+
username: ${{ github.actor }}
56+
password: ${{ github.token }}
57+
58+
- name: Lowercase the repo name and username
59+
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
60+
61+
- name: Build and push container image to registry
62+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
63+
with:
64+
push: true
65+
tags: ghcr.io/${{ env.REPO }}:${{ github.sha }}
66+
file: ./ShowcaseFrontend/Dockerfile
67+
68+
deploy:
69+
permissions:
70+
contents: none
71+
runs-on: ubuntu-latest
72+
needs: build
73+
environment:
74+
name: 'Development'
75+
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
76+
77+
steps:
78+
- name: Lowercase the repo name and username
79+
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
80+
81+
- name: Deploy to Azure Web App
82+
id: deploy-to-webapp
83+
uses: azure/webapps-deploy@v2
84+
with:
85+
app-name: ${{ env.AZURE_WEBAPP_NAME }}
86+
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
87+
images: 'ghcr.io/${{ env.REPO }}:${{ github.sha }}'

0 commit comments

Comments
 (0)