-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (112 loc) · 3.7 KB
/
deploy.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Build and Deploy
on:
push:
branches:
- staging
- production
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
environment: |-
${{
github.ref_name == 'production' && 'production'
|| github.ref_name == 'staging' && 'staging'
|| 'development'
}}
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: secret
POSTGRES_DB: namukilke
POSTGRES_USER: namukilke
options: >-
--health-cmd pg_isready
--health-interval 6s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Log in to Azure
- name: Azure Login
uses: azure/login@v1
with:
client-id: ${{ secrets.CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
allow-no-subscriptions: true
# Login to ACR
- name: login to ACR
run: az acr login --name ${{ secrets.ACR_REGISTRY_NAME }}
# Set up Docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
network=host
cleanup: true
# Build the docker image
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ secrets.ACR_REGISTRY_NAME }}.azurecr.io/namukilke/namukilke:${{ github.sha }}
# There is intentionally no scope on the cache due to github's cache access restrictions.
# Both the release and debug file will now be stored in the same location.
# cache-from: type=gha
# cache-to: type=gha,mode=max
build-args: |
"DATABASE_URL=postgres://namukilke:secret@localhost:5432/namukilke"
"NEXT_PUBLIC_STRIPE_TESTMODE_PUBLISHABLE_KEY=${{ vars.NEXT_PUBLIC_STRIPE_TESTMODE_PUBLISHABLE_KEY }}"
"NEXT_PUBLIC_AZURE_BLOB_STORAGE_URL=${{ vars.NEXT_PUBLIC_AZURE_BLOB_STORAGE_URL }}"
"NEXT_PUBLIC_AZURE_BLOB_CONTAINER_NAME=${{ vars.NEXT_PUBLIC_AZURE_BLOB_CONTAINER_NAME }}"
"NEXT_PUBLIC_URL_PROD=${{ vars.NEXT_PUBLIC_URL_PROD }}"
"SKIP_ENV_VALIDATION=true"
allow: |
network.host
security.insecure
network: host
# Logout
- name: Azure logout
run: |
az logout
deploy:
runs-on: ubuntu-latest
needs: build
environment: |-
${{
github.ref_name == 'production' && 'production'
|| github.ref_name == 'staging' && 'staging'
|| 'development'
}}
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Log in to Azure
- name: Azure Login
uses: azure/login@v1
with:
client-id: ${{ secrets.CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
allow-no-subscriptions: true
- name: Docker login to ACR
run: az acr login --name ${{ secrets.ACR_REGISTRY_NAME }}
- name: Deploy from ACR
run: |
az webapp config container set \
--container-image-name ${{ secrets.ACR_REGISTRY_NAME }}.azurecr.io/namukilke/namukilke:${{ github.sha }} \
--container-registry-url https://${{ secrets.ACR_REGISTRY_NAME }}.azurecr.io \
--subscription ${{ secrets.SUBSCRIPTION }} \
--resource-group prodeko-rg \
--name ${{ vars.WEB_APP_NAME }}
- name: Azure logout
run: |
az logout