-
Notifications
You must be signed in to change notification settings - Fork 3
52 lines (49 loc) · 2 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
name: Build and Deploy
on:
push:
branches:
- main
env:
JOB_STARTED_AT: ${{ github.event.created_at }}
CR_REGISTRY: ${{ secrets.CR_REGISTRY }}
CR_IMAGE_FRONTEND: ${{ secrets.CR_IMAGE_FRONTEND }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Registry
uses: yc-actions/yc-cr-login@v1
with:
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
- name: Build and Push Image
run: |
docker build \
--build-arg NEXT_PUBLIC_CDN_ENDPOINT_URL=https://mn-lost-and-found.storage.yandexcloud.net \
--build-arg NEXT_PUBLIC_S3_UPLOAD_RESOURCE_FORMATS=.png,.jpg,.jpeg,.gif,.webp \
--build-arg NEXT_PUBLIC_NEXTAUTH_URL=https://finds.mirea.ninja \
--pull \
--cache-from cr.yandex/${{ env.CR_REGISTRY }}/${{ env.CR_IMAGE_FRONTEND }}:latest \
--label "org.image.title=${{ github.repository }}" \
--label "org.image.url=${{ github.repositoryUrl }}" \
--label "org.image.created=${{ env.JOB_STARTED_AT }}" \
--label "org.image.revision=${{ github.ref_name }}" \
--label "org.image.version=${{ github.sha }}" \
--tag cr.yandex/${{ env.CR_REGISTRY }}/${{ env.CR_IMAGE_FRONTEND }}:${{ github.sha }} \
.
docker push cr.yandex/${{ env.CR_REGISTRY }}/${{ env.CR_IMAGE_FRONTEND }}:${{ github.sha }}
docker tag cr.yandex/${{ env.CR_REGISTRY }}/${{ env.CR_IMAGE_FRONTEND }}:${{ github.sha }} \
cr.yandex/${{ env.CR_REGISTRY }}/${{ env.CR_IMAGE_FRONTEND }}:latest
docker push cr.yandex/${{ env.CR_REGISTRY }}/${{ env.CR_IMAGE_FRONTEND }}:latest
deploy:
runs-on: self-hosted
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Deploy
run: |
cd ${{ secrets.PRODUCTION_FOLDER }}
docker compose --env-file .env.local pull
docker compose --env-file .env.local up -d