-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (62 loc) · 2.92 KB
/
prod.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
64
65
66
67
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
pull_request:
branches: [ "main" ]
types: [opened, synchronize, reopened]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# 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 "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
EC2_SSH_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
EC2_URL: ${{ secrets.EC2_HOST }}
EC2_USERNAME: ${{ secrets.EC2_USER }}
GIT_PAT: ${{ secrets.GIT_PAT }}
if: github.head_ref == 'dev'
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Setup SSH for EC2
uses: omarhosny206/[email protected]
with:
EC2_SSH_PRIVATE_KEY: $EC2_SSH_PRIVATE_KEY
EC2_URL: $EC2_URL
# then you can run commands/scripts directly on the EC2 instance e.g.:a
- name: Remove app folder"
run: |
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "rm -rf ~/testGha"
# Install docker & docker compose
- name: Install docker
run: |
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "sudo yum update && sudo yum -y install docker"
- name: Add group membership for the default ec2-user
run: |
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "sudo usermod -a -G docker ec2-user && id ec2-user && newgrp docker"
- name: Install docker-compose
run: |
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "wget https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) && sudo mv docker-compose-$(uname -s)-$(uname -m) /usr/local/bin/docker-compose && sudo chmod -v +x /usr/local/bin/docker-compose"
- name: Enable docker service at AMI boot time
run: |
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "sudo systemctl enable docker.service && sudo systemctl start docker.service"
- name: check Docker install
run: |
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "sudo systemctl status docker.service"
- name: Install python3
run: |
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "sudo yum -y install python3"
# Install git and clone repo
- name: Install git
run: |
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "sudo yum -y install git"
- name: Set Git Username and Password
run: |
ssh -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_URL "git config --global user.name "dst" && git config --global user.password $GIT_PATH"
- name: Clone repo
run: |
git clone https://github.com/DstMlOpsCrypto/testGha.git