-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (49 loc) · 1.55 KB
/
main.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
name: BE CI/CD
on: [push, pull_request]
jobs:
build:
name: CI
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.ACTION_TOKEN }} # personal token
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
# - name: get time for image tag
# id: time
# run: echo "::set-output name=tag::$(date +'%Y%m%d%H%M%S')"
- name: Build image in EC2
id: build-image
run: |
docker build -t be:latest .
- name: Stop and remove previous container
run: |
docker rmi -f backend || true
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
# - name: Pull image from Amazon ECR and run container
# continue-on-error: true
# run: |
# cd ~/BE
# docker rmi be:
# docker-compose up -d
- name: Pull image from Amazon ECR and run container
run: |
docker run -d --name backend backend:latest
# deploy:
# needs: build
# name: CD
# runs-on: self-hosted
# if: github.ref == 'refs/heads/deploy'
# steps: