-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from bouvet/CI/remove-pr-environments-on-close
Ci/remove pr environments on close
- Loading branch information
Showing
6 changed files
with
132 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Build and Deploy to Production | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
paths: | ||
- 'Bouvet.Developer.Survey.Backend/**' | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: 'Branch to deploy' | ||
required: true | ||
default: 'main' | ||
|
||
env: | ||
DOTNET_VERSION: '8.0' | ||
IMAGE_TAG: ${{ github.sha }} | ||
|
||
jobs: | ||
build-project: | ||
runs-on: ubuntu-latest | ||
name: Build 🛠️ | ||
container: | ||
image: mcr.microsoft.com/dotnet/sdk:8.0 | ||
steps: | ||
- name: Checkout project | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up .NET Core | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
||
- name: Dotnet restore | ||
working-directory: ./Bouvet.Developer.Survey.Backend | ||
run: dotnet restore Bouvet.Developer.Survey.Backend.generated.sln | ||
|
||
- name: Build with dotnet | ||
working-directory: ./Bouvet.Developer.Survey.Backend | ||
run: dotnet build Bouvet.Developer.Survey.Backend.generated.sln --configuration Release --no-restore | ||
|
||
- name: Publish | ||
working-directory: ./Bouvet.Developer.Survey.Backend | ||
run: dotnet publish Bouvet.Developer.Survey.Backend.generated.sln --configuration Release --no-build | ||
|
||
deploy-to-prod: | ||
runs-on: ubuntu-latest | ||
name: Deploy to Production | ||
environment: Production | ||
needs: [build-project] # No dependency on test or preview environment | ||
|
||
defaults: | ||
run: | ||
working-directory: ./Bouvet.Developer.Survey.Backend | ||
steps: | ||
- name: Checkout GitHub Action | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login via Azure CLI | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Enable ACR Admin Account | ||
run: | | ||
az acr update -n bouvetSurveyContainerRegistryProd --admin-enabled true | ||
- name: Get ACR name | ||
id: getacrname | ||
run: | | ||
acrName=$(az acr list --resource-group ${{ secrets.AZURE_RG }} --query "[0].name" -o tsv) | ||
echo "ACR_NAME=$acrName" >> $GITHUB_ENV | ||
- name: Get ACR Credentials | ||
id: getacrcreds | ||
run: | | ||
loginServer=$(az acr list --resource-group ${{ secrets.AZURE_RG }} --query "[0].loginServer" -o tsv) | ||
loginName=$(az acr credential show -n ${{ env.ACR_NAME }} --resource-group ${{ secrets.AZURE_RG }} --query username -o tsv) | ||
password=$(az acr credential show -n ${{ env.ACR_NAME }} --resource-group ${{ secrets.AZURE_RG }} --query "passwords[0].value" -o tsv) | ||
echo "LOGIN_SERVER=$loginServer" >> $GITHUB_ENV | ||
echo "LOGIN_NAME=$loginName" >> $GITHUB_ENV | ||
echo "PASSWORD=$password" >> $GITHUB_ENV | ||
- name: Build and Push API Image to ACR | ||
uses: azure/docker-login@v1 | ||
with: | ||
login-server: ${{ env.LOGIN_SERVER }} | ||
username: ${{ env.LOGIN_NAME }} | ||
password: ${{ env.PASSWORD }} | ||
- run: | | ||
docker build . -t ${{ env.LOGIN_SERVER }}/backend-image:${{ github.sha }} | ||
docker push ${{ env.LOGIN_SERVER }}/backend-image:${{ github.sha }} | ||
echo "IMAGE_TAG=${{ github.sha }}" >> $GITHUB_ENV | ||
- name: Update Container App Image | ||
run: | | ||
az containerapp update \ | ||
--name bds-prod-containerapp-api \ | ||
--resource-group ${{ secrets.AZURE_RG_PROD }} \ | ||
--image ${{ env.LOGIN_SERVER }}/backend-image:${{ github.sha }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters