-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (52 loc) · 1.92 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
name: Deploy
on:
push:
branches: [ master, dev ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "deploy"
deploy:
runs-on: ubuntu-latest
steps:
# Спуливаем содержимое
- uses: actions/checkout@v2
# Устанавливаем
- name: Extract branch name
shell: bash
run: |
echo "::set-env name=BRANCH_NAME::${GITHUB_REF##*/}"
echo "${{ env.BRANCH_NAME }}"
# Собираем контейнер
- name: Build and push image
uses: docker/build-push-action@v1.1.0
with:
repository: hw_back_${{ env.BRANCH_NAME }}
dockerfile: ./conf/docker/Dockerfile
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
tags: new
- name: Docker Login
uses: Azure/docker-login@v1
with:
login-server: https://${{ secrets.DOCKER_REGISTRY }}/v2/
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Запускаем тесты
- name: Run tests
run: |
export HW_ENV=${{ env.BRANCH_NAME }}
export DOCKER_REGISTRY=${{ secrets.DOCKER_REGISTRY }}
docker-compose -f docker-compose.test.yml run --rm test_web
docker-compose -f docker-compose.test.yml down --remove-orphans
# Деплой
- name: Deploy prod
if: env.BRANCH_NAME == 'master'
uses: wei/curl@v1.1.1
with:
args: -X POST ${{ secrets.DEPLOY_HOST }}/modules/git/public/web-hook.php?uuid=${{ secrets.DEPLOY_BACK_PROD_TOKEN }}
- name: Deploy dev
if: env.BRANCH_NAME == 'dev'
uses: wei/curl@v1.1.1
with:
args: -X POST ${{ secrets.DEPLOY_HOST }}/modules/git/public/web-hook.php?uuid=${{ secrets.DEPLOY_BACK_DEV_TOKEN }}