-
Notifications
You must be signed in to change notification settings - Fork 86
76 lines (70 loc) · 2.69 KB
/
deploy_testnet.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
68
69
70
71
72
73
74
75
76
name: Deploy TESTNET Seed
on:
workflow_dispatch:
inputs:
ref:
description: 'Tag or branch to deploy'
default: 'main'
# workflow_run:
# workflows: ["Build Docker And Deploy Seed"]
# types:
# - completed
jobs:
deploy-rooch-testnet:
name: Deploy Rooch Testnet
runs-on: self-hosted
if: |
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'release' &&
(github.event.release.prerelease == true || github.event.release.prerelease == false))
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Download Docker tag artifact
if: github.event_name == 'workflow_run'
uses: actions/download-artifact@v4
with:
name: docker_tag
path: .
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GIT_PACKAGE_TOKEN }}
- name: Determine ref
id: determine-ref
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "REF=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
else
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
echo "REF=$(cat docker_tag.txt)" >> $GITHUB_ENV
else
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
REF=${GITHUB_REF#refs/tags/}
elif [[ "${{ github.ref }}" == refs/heads/* ]]; then
REF=${GITHUB_REF#refs/heads/}
fi
echo "REF=$REF" >> $GITHUB_ENV
fi
fi
- name: Print ref
run: echo "The Tag Ref is ${{ env.REF }} and The Branch Ref is ${{ github.ref }}"
- name: Deploy to GCP TESTNET VM
env:
PRIVATE_KEY: ${{ secrets.GCP_TESTNET_SSH_PRIVATE_KEY }}
HOST: ${{ secrets.GCP_TESTNET_VM_HOST }}
USER: ${{ secrets.GCP_TESTNET_VM_USER }}
run: |
echo "$PRIVATE_KEY" > private_key.pem
chmod 600 private_key.pem
sudo apt update
sudo apt install -y --no-install-recommends openssh-server
BRANCH=$(basename ${{ github.ref }})
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST \
"cd /root/rooch && git fetch origin && git checkout -B $BRANCH origin/$BRANCH || git checkout $BRANCH && bash scripts/deploy_rooch.sh \
'${{ env.REF }}' \
'${{ secrets.BTC_TEST_RPC_URL }}' \
'${{ secrets.BTC_TEST_RPC_PWD }}' \
'${{ secrets.OPENDA_GCP_TESTNET_BUCKET }}' \
'${{ secrets.OPENDA_GCP_TESTNET_CREDENTIAL }}'"