Merge pull request #143 from TomaszKandula/stage #38
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 (master) | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
versioning: | |
runs-on: ubuntu-latest | |
outputs: | |
outputs1: ${{ steps.versioning.outputs.version }} | |
outputs2: ${{ steps.versioning.outputs.published }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Semantic Release (install node.js) | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Semantic Release (install dependencies) | |
run: | | |
npm install --global yarn | |
yarn install | |
- name: Semantic Release (process changes) | |
uses: cycjimmy/semantic-release-action@v4.0.0 | |
id: semantic | |
env: | |
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} | |
- name: Move results to outputs | |
id: versioning | |
run: | | |
echo "version=${{ steps.semantic.outputs.new_release_version }}" >> $GITHUB_OUTPUT | |
echo "published=${{ steps.semantic.outputs.new_release_published }}" >> $GITHUB_OUTPUT | |
backend-production: | |
runs-on: ubuntu-latest | |
needs: versioning | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Variable substitution appsettings file for Production (NET Core) | |
uses: TomaszKandula/variable-substitution@v1.0.2 | |
with: | |
files: ${{ github.workspace }}/EmailSender.Configuration/appsettings.Production.json | |
env: | |
DbConnect: "${{ secrets.DBCONNECT_PROD }}" | |
AZ_Storage_ContainerName: "${{ secrets.STORAGE_CONTAINER_NAME_PROD }}" | |
AZ_Storage_ConnectionString: "${{ secrets.STORAGE_CONNECTION_STRING }}" | |
- name: Production | 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: Production | Build Docker (execute with tests) | |
run: | | |
docker build . \ | |
-t ${{ secrets.DOCKER_REGISTRY_SERVER_URL }}/${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }}:backend-production-${{ github.sha }} | |
- name: Production | 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: Production | Push Docker image | |
if: needs.versioning.outputs.outputs2 == 'true' | |
run: docker push ${{ secrets.DOCKER_REGISTRY_SERVER_URL }}/${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }}:backend-production-${{ github.sha }} | |
- name: Production | Deploy to Azure Web App | |
uses: azure/webapps-deploy@v3 | |
if: needs.versioning.outputs.outputs2 == 'true' | |
with: | |
app-name: emailsender-west-production | |
slot-name: production | |
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE_BACKEND_PROD }} | |
images: ${{ secrets.DOCKER_REGISTRY_SERVER_URL }}/${{ secrets.DOCKER_REGISTRY_SERVER_USERNAME }}:backend-production-${{ github.sha }} |