-
Notifications
You must be signed in to change notification settings - Fork 3
62 lines (55 loc) · 2.01 KB
/
deploy.yaml
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
name: build on docker hub and deploy to aws
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: set up docker buildx
uses: docker/setup-buildx-action@v1
- name: log in to docker hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: build and push docker image
uses: docker/build-push-action@v2
with:
context: ./
push: true
dockerfile: ./Dockerfile
tags: rohansinghagent/lainforge-home:latest
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: log in to docker hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: set permissions for private-key
run: |
echo "${{ secrets.AWS_PRIVATE_KEY }}" > key.pem
chmod 600 key.pem
- name: Download new docker compose file
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@18.140.65.193 'curl -LJO https://github.com/LainForge/LainForge.github.io/raw/main/.github/compose/production.yaml'
- name: Bring down already running docker containers
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@18.140.65.193 'docker kill $(docker ps -q)'
- name: Delete old images
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@18.140.65.193 'docker rm $(docker ps -aq --filter status="exited")'
- name: Pull latest images from docker compose
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@18.140.65.193 'docker-compose -f production.yaml pull'
- name: Restart using docker compose
run: |
ssh -o StrictHostKeyChecking=no -i key.pem ubuntu@18.140.65.193 'docker-compose -f production.yaml up -d'