-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (72 loc) · 3.08 KB
/
master_build_test_publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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 "::set-output name=version::${{ steps.semantic.outputs.new_release_version }}"
echo "::set-output name=published::${{ steps.semantic.outputs.new_release_published }}"
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: microsoft/variable-substitution@v1
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 }}