forked from ubiquity/pay.ubq.fi
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (119 loc) · 4.91 KB
/
deploy.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Deploy to Cloudflare Pages
on:
workflow_run:
workflows: ["Build"]
types:
- completed
jobs:
deploy-to-cloudflare:
name: Automatic Cloudflare Deploy
runs-on: ubuntu-22.04
steps:
- name: Verify Runner's Identity
id: verify-runner
run: |
echo "Runner name: $RUNNER_NAME"
if [[ "$RUNNER_NAME" != *"GitHub Actions"* ]]; then
echo "This workflow must run on a GitHub Actions runner. (github-actions[bot])"
exit 1
fi
- name: Deploy to Cloudflare
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ubiquity/cloudflare-deploy-action@main
with:
repository: ${{ github.repository }}
production_branch: ${{ github.event.repository.default_branch }}
build_artifact_name: "full-stack-app"
output_directory: "full-stack-app"
current_branch: ${{ github.event.workflow_run.head_branch }}
cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
commit_sha: ${{ github.event.workflow_run.head_sha }}
workflow_run_id: ${{ github.event.workflow_run.id }}
statics_directory: "static"
- name: Check out repository
uses: actions/checkout@v4
- name: Make env sync script executable
run: chmod +x .github/sync-env-vars.sh
- name: Run env sync script script
env:
GITHUB_REPOSITORY: ${{ github.repository }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
RELOADLY_API_CLIENT_ID: ${{ secrets.RELOADLY_API_CLIENT_ID }}
RELOADLY_API_CLIENT_SECRET: ${{ secrets.RELOADLY_API_CLIENT_SECRET }}
RELOADLY_SANDBOX_API_CLIENT_ID: ${{ secrets.RELOADLY_SANDBOX_API_CLIENT_ID }}
RELOADLY_SANDBOX_API_CLIENT_SECRET: ${{ secrets.RELOADLY_SANDBOX_API_CLIENT_SECRET }}
run: bash .github/sync-env-vars.sh
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.10.0
- name: Generate Claimable Permit
id: permit_generation
# The sed command is used to remove color characters that are present in the output of the script
run: |
yarn
output=$(yarn "start:sign")
url=$(echo $output | grep -o "https://[^ ]*" | sed -n '2p' | sed 's/\x1B\[[0-9;]*[JKmsu]//g')
echo $output
echo "Permit available at the address:"
echo $url
echo "CLAIMABLE_URL=$url" >> $GITHUB_ENV
env:
BENEFICIARY_ADDRESS: "0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd"
PAYMENT_TOKEN_ADDRESS: "0xC6ed4f520f6A4e4DC27273509239b7F8A68d2068"
AMOUNT_IN_ETH: 30
CHAIN_ID: 100
FRONTEND_URL: "${{ env.DEPLOYMENT_URL }}"
BACKEND_URL: ""
RPC_PROVIDER_URL: "https://rpc.ankr.com/gnosis"
UBIQUIBOT_PRIVATE_KEY: ${{ secrets.UBIQUIBOT_APP_PRIVATE_KEY_TEST }}
- uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const sha = "${{ github.event.workflow_run.head_sha }}";
const response = await github.rest.search.issuesAndPullRequests({
q: `repo:${owner}/${repo} is:pr sha:${sha}`,
per_page: 1,
});
const items = response.data.items;
if (items.length < 1) {
console.error('No related PRs found, skipping.');
return;
}
const issue_number = items[0].number;
console.info('Pull request number is', issue_number);
if (!issue_number) {
console.log('Action not triggered from an issue, skipping.');
return;
}
// Fetch existing comments on the issue
const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number,
});
// Look for an existing "Preview Deployment" comment
let previewComment = comments.data.find(comment =>
comment.body.startsWith("| Preview Deployment |")
);
const body = `| Preview Deployment |\n| ------------------ |\n| [${sha}](${{ env.CLAIMABLE_URL }}) |\n`;
if (previewComment) {
// Update the existing "Preview Deployment" comment
await github.rest.issues.updateComment({
owner,
repo,
comment_id: previewComment.id,
body
});
} else {
// Create a new "Preview Deployment" comment if not found
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body
});
}