-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (37 loc) · 1.77 KB
/
deploy.yml
File metadata and controls
43 lines (37 loc) · 1.77 KB
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
name: Deploy to Azure
on:
push:
branches: [development, master]
env:
CURRENT_ENV: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
jobs:
build:
environment: ${{ github.ref == 'refs/heads/master' && 'production' || 'development' }}
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Azure Container Registry login
uses: docker/login-action@v2
with:
registry: ${{ secrets.AZ_REGISTRY_URL }}
username: ${{ secrets.AZ_REGISTRY_USERNAME }}
password: ${{ secrets.AZ_REGISTRY_PASSWORD }}
- name: Build, tag and push image to Azure Container Registry
env:
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
ENV_FILE: ${{ secrets.ENV }}
ECR_REGISTRY: ${{ secrets.AZ_REGISTRY_URL }}
ECR_REPOSITORY: collaction-api-${{ env.CURRENT_ENV }}
run: |
echo $SERVICE_ACCOUNT_KEY | base64 --decode > serviceAccountKey.json
echo $ENV_FILE | base64 --decode > .env
docker build --target ${{ env.CURRENT_ENV }} -t $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }} .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${{ github.sha }}
- name: Deploy to Azure App Service
uses: azure/webapps-deploy@v2
with:
app-name: 'collaction-api-${{ env.CURRENT_ENV }}'
publish-profile: ${{ secrets.AZ_PUBLISH_PROFILE }}
images: '${{ secrets.AZ_REGISTRY_URL }}/collaction-api-${{ env.CURRENT_ENV }}:${{ github.sha }}'