This repository has been archived by the owner on Apr 6, 2024. It is now read-only.
Merge pull request #149 from TomaszKandula/dev #59
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
name: Build, test and publish (stage) | |
on: | |
push: | |
branches: [ stage ] | |
jobs: | |
backend-staging: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Variable substitution appsettings file for Staging (NET Core) | |
uses: TomaszKandula/variable-substitution@v1.0.1 | |
with: | |
files: ${{ github.workspace }}/InvoiceGenerator.Configuration/appsettings.Staging.json | |
env: | |
DbConnect: "${{ secrets.DBCONNECT_STAGE }}" | |
AZ_Storage_ContainerName: "${{ secrets.STORAGE_CONTAINER_NAME_STAGE }}" | |
AZ_Storage_ConnectionString: "${{ secrets.STORAGE_CONNECTION_STRING }}" | |
- name: Staging | Build Docker (prepare) | |
uses: azure/docker-login@v1.0.1 | |
with: | |
login-server: ${{ secrets.DOCKER_REGISTRY_SERVER_URL }} | |
username: ${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }} | |
password: ${{ secrets.DOCKER_REGISTRY_SERVER_PASSWORD }} | |
- name: Staging | Build Docker (execute with tests) | |
run: docker build -f webapi.dockerfile -t ${{ secrets.DOCKER_REGISTRY_SERVER_URL }}/${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }}:backend-staging-${{ github.sha }} . | |
- name: Staging | Push Docker image (prepare) | |
uses: azure/docker-login@v1.0.1 | |
with: | |
login-server: ${{ secrets.DOCKER_REGISTRY_SERVER_URL }} | |
username: ${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }} | |
password: ${{ secrets.DOCKER_REGISTRY_SERVER_PASSWORD }} | |
- name: Staging | Push Docker image | |
run: docker push ${{ secrets.DOCKER_REGISTRY_SERVER_URL }}/${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }}:backend-staging-${{ github.sha }} | |
# Note: due to a budget constraints, we use separate Azure App Service for staging as the separate slots | |
# are unavailable for B1, B2 and B3 pricing tiers | |
- name: Staging | Deploy to Azure Web App | |
uses: azure/webapps-deploy@v3 | |
with: | |
app-name: invoicegenerator-staging | |
slot-name: production | |
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE_BACKEND_STAGE }} | |
images: ${{ secrets.DOCKER_REGISTRY_SERVER_URL }}/${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }}:backend-staging-${{ github.sha }} | |
workers-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.DOCKER_REGISTRY_SERVER_URL }} | |
username: ${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }} | |
password: ${{ secrets.DOCKER_REGISTRY_SERVER_PASSWORD }} | |
- name: Build and push container image to registry | |
uses: docker/build-push-action@v5.1.0 | |
with: | |
push: true | |
tags: ${{ secrets.DOCKER_REGISTRY_SERVER_URL }}/${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }}:workers-staging-${{ github.sha }} | |
file: ./workers.dockerfile | |
workers-deploy: | |
runs-on: ubuntu-latest | |
needs: workers-build | |
environment: | |
name: production | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
steps: | |
- name: Deploy to Azure Web App | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v3 | |
with: | |
app-name: invoicegenerator-func-staging | |
slot-name: production | |
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE_FUNC_STAGE }} | |
images: ${{ secrets.DOCKER_REGISTRY_SERVER_URL }}/${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }}:workers-staging-${{ github.sha }} |