-
Notifications
You must be signed in to change notification settings - Fork 1
56 lines (47 loc) · 1.49 KB
/
build-and-deploy.yml
File metadata and controls
56 lines (47 loc) · 1.49 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
44
45
46
47
48
49
50
51
52
53
54
55
56
# Workflow name
name: Deploy application
# Triggers
on:
workflow_dispatch:
push:
branches:
- admin-page
- development
- production
# Actions
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Set build profile
# Set default state of PROFILE to dev
run: echo "PROFILE=dev" >> $GITHUB_ENV
# If branch is production sed PROFILE to prod
- if: github.ref == 'refs/heads/production'
run: echo "PROFILE=prod" >> $GITHUB_ENV
- name: Print PROFILE env
shell: bash
run: echo profile is :${PROFILE}
- name: Check out the repo
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Docker-compose build
shell: bash
run: docker-compose -f .deploy/docker-compose.build.yml --profile ${PROFILE} build --no-cache
- name: Docker-compose push
shell: bash
run: docker-compose -f .deploy/docker-compose.build.yml --profile ${PROFILE} push
- name: Execute docker-compose up through SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_HOST }}
username: ${{ secrets.AWS_USER }}
key: ${{ secrets.SSH_KEY }}
envs: PROFILE
script: |
echo $PROFILE
~/scripts/login-and-update.sh $PROFILE up -d