Skip to content
59 changes: 10 additions & 49 deletions .github/workflows/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
build-images:
runs-on: ubuntu-latest
name: Build Docker images for Azure Container Registry and GitHub Container Registry
environment:
name: build
permissions:
contents: read
packages: write
Expand All @@ -27,62 +25,25 @@ jobs:
with:
fetch-depth: 0

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.GH_REGISTRY_URL }}/${{ env.IMAGE_NAME }},${{ secrets.AZURE_REGISTRY_URL }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,format=long,suffix=,prefix=
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: ACR authentication
uses: azure/docker-login@v2
with:
login-server: ${{ secrets.AZURE_REGISTRY_URL }}
username: ${{ secrets.AZURE_REGISTRY_USERNAME }}
password: ${{ secrets.AZURE_REGISTRY_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: GPR authentication
uses: azure/docker-login@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
login-server: ${{ secrets.GH_REGISTRY_URL }}
registry: ghcr.io/sarathkrishnamurthy/httpstatus
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: src/Teapot.Web/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ghcr.io/sarathkrishnamurthy/httpstatus:test5
labels: test-label
platforms: linux/amd64,linux/arm64

deploy-azure:
runs-on: ubuntu-latest
name: Deploy to Azure
environment:
name: production
needs: [build-images]

steps:
- name: Azure authentication
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Deploy to Azure WebApp
uses: azure/webapps-deploy@v3
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
images: ${{ secrets.AZURE_REGISTRY_URL }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
2 changes: 1 addition & 1 deletion src/Teapot.Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS base
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
Expand Down