-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (54 loc) · 1.93 KB
/
gitPaid.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: 'gitPaid'
on:
pull_request:
branches:
- main
paths: ['source_documents/**']
types: [closed]
permissions:
contents: read
pull-requests: write
env:
LND_SERVER: ${{ secrets.LND_SERVER }}
LND_SSH_KEY: ${{ secrets.LND_SSH_KEY }}
jobs:
gitPaid:
runs-on: ubuntu-latest
environment: AI4ALL
defaults:
run:
shell: bash
# Verify this is a merge event
if: ${{ github.event.pull_request.merged }} == 'true'
steps:
- name: Verify LND Connectivity
id: verify_lnd_connectivity
run: |
timeout 5 bash -c "</dev/tcp/$LND_SERVER/22"
if [ $? != '0' ]; then
echo "[ ERROR ] - The LND_SERVER Environment variable is failing to listen for SSH connections. Perhaps the Hackathon is over? Feel free to fork for yourself!"
exit 1
else
echo "[ INFO ] - The LND Server is connected and ready to go!"
fi
- name: Generate Invoice and Send Payment
id: generate_invoice_and_send_payment
continue-on-error: true # To display errmsg
run: |
# Genereate invoice
MEMO='Thank%20you%20for%20your%20contribution!' # Base64 encoded string
AMOUNT='85' # Sats to send
curl -s https://www.lnurlpay.com/${{ github.event.pull_request.title }}/$AMOUNT?comment=$MEMO > invoiceToParse.html
INV=$(cat invoiceToParse.html | tr '"' '\n' | grep lnbc)
if [ -z $INV ]; then
echo "Invalid lightning address. We will take your contribution, but you won't get paid!"
exit 1
fi
# Send Payment
echo "Paying LN Invoice: "$INV
key_path='/tmp/lnd_ssh_key.pem'
echo "${{ secrets.LND_SSH_KEY }}" > $key_path
chmod 600 $key_path
eval $(ssh-agent) > /dev/null
ssh-add $key_path
ssh -o StrictHostKeyChecking=no ubuntu@$LND_SERVER "/home/ubuntu/lnd-linux-amd64-v0.16.4-beta/lncli sendpayment --pay_req=$INV --force > /dev/null"