-
Notifications
You must be signed in to change notification settings - Fork 3
60 lines (60 loc) · 2.33 KB
/
start_process.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
name: start_process
on:
workflow_call:
secrets:
INSTANCE_ID:
required: true
INSTANCE_IP:
required: true
SSH_KEY:
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
jobs:
call_context_check:
uses: dj-sciops/djsciops-cicd/.github/workflows/context_check.yaml@main
start_process:
needs: call_context_check
runs-on: ubuntu-latest
env:
INSTANCE_ID: ${{ secrets.INSTANCE_ID }}
INSTANCE_IP: ${{ secrets.INSTANCE_IP }}
SSH_KEY: ${{ secrets.SSH_KEY }}
REPO_NAME: ${{ github.event.repository.name }}
steps:
- 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: us-east-1
- name: start worker instance
run: |
echo "INFO::start worker instance"
aws ec2 start-instances --instance-ids ${INSTANCE_ID}
sleep 90
- name: setup ssh key on this GHA runner
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: start process
run: |
echo "INFO::start process"
ssh \
-o "StrictHostKeyChecking no" \
-o "TCPKeepAlive no" \
-o "IPQoS throughput" \
-o "ServerAliveInterval 43200" \
-o "ServerAliveCountMax 5" \
ubuntu@${INSTANCE_IP} \
"sudo rm -rf /home/ubuntu/ArsenyLabWorkflow; \
git clone -b $GITHUB_REF_NAME https://github.com/${GITHUB_REPOSITORY}.git /home/ubuntu/ArsenyLabWorkflow; \
cp .FinkelsteinLab.env ArsenyLabWorkflow/docker/standard_worker/.env; \
sed -i 's/REPO_OWNER=ArsenyFinkelsteinLab/REPO_OWNER=${GITHUB_REPOSITORY_OWNER}/g' ArsenyLabWorkflow/docker/standard_worker/.env; \
sed -i 's/REPO_NAME=DJ_cloud/REPO_NAME=${REPO_NAME}/g' ArsenyLabWorkflow/docker/standard_worker/.env; \
sed -i 's/BRANCH_NAME=main/BRANCH_NAME=${GITHUB_REF_NAME}/g' ArsenyLabWorkflow/docker/standard_worker/.env; \
screen -d -m bash /home/ubuntu/ArsenyLabWorkflow/entrypoint.sh; \
"
echo "INFO::process started"