-
Notifications
You must be signed in to change notification settings - Fork 7
127 lines (116 loc) · 3.68 KB
/
deploy-pr.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
---
name: ♻ PR Deployment
on:
issue_comment:
types: [ created ]
jobs:
build:
name: Build
needs:
- run
uses: ./.github/workflows/tpl-images.yml
secrets: inherit
with:
image-tag: ${{ needs.run.outputs.sha }}
git-ref: ${{ needs.run.outputs.ref }}
deploy:
name: Deploy
needs:
- run
- build
uses: ./.github/workflows/tpl-deploy-app.yml
with:
# ---
env-type: pr
branch-head-ref: ${{ needs.run.outputs.ref }}
image-tag: ${{ needs.run.outputs.sha }}
pull-request-id: ${{ needs.run.outputs.pr_id }}
workflow-id: ${{ github.run_id }}
env-id: ${{ needs.run.outputs.env }}
deployment-id: ${{ needs.run.outputs.deployment }}
# ---
deploy-contracts: true
chain-id: 1337
network-name: local
chain-name: localhost
snapshotter-enabled: true
scheduler-enabled: true
vault-confirm-withdrawals-enabled: true
glm-claim-enabled: true
anvil-block-time: 5
decision-window: 1800
epoch-duration: 3600
secrets: inherit
run:
name: Run
if: github.event.issue.pull_request && contains(github.event.comment.body, '/deploy')
runs-on:
- metal
outputs:
sha: ${{ steps.comment-branch.outputs.head_sha }}
ref: ${{ steps.comment-branch.outputs.head_ref }}
pr_id: ${{ steps.get-pr-number.outputs.result }}
env: ${{ steps.start-deployment.outputs.env }}
deployment: ${{ steps.start-deployment.outputs.deployment_id }}
steps:
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
- name: Check if user is an org member
uses: actions/github-script@v7
id: is-organization-member
with:
result-encoding: string
github-token: ${{ secrets.GH_BOT_TOKEN }}
script: |
return (
await github.rest.orgs.listMembers({
org: 'golemfoundation'
})
).data.map(({login}) => login).includes('${{ github.event.comment.user.login }}').toString()
- name: Cancel workflow
if: ${{ steps.is-organization-member.outputs.result == 'false' }}
run: |
echo '${{ github.event.comment.user.login }} is not a member of the golemfoundation org'
exit 1
- uses: actions/github-script@v7
id: get-pr-number
with:
result-encoding: string
script: |
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: '${{ steps.comment-branch.outputs.head_sha }}',
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0].number;
- uses: actions/[email protected]
with:
path: __local
ref: ${{ steps.comment-branch.outputs.head_ref }}
- name: Get environment name
id: env-name
env:
CI_MERGE_REQUEST_IID: ${{ steps.get-pr-number.outputs.result }}
CI_PIPELINE_ID: ${{ github.run_id }}
run: |
set -ex
export CI_PROJECT_DIR="${GITHUB_WORKSPACE}/__local"
source ${CI_PROJECT_DIR}/ci/argocd/resolve_env.sh $ENV_TYPE
echo "DEPLOYMENT_ID=$DEPLOYMENT_ID" >> $GITHUB_OUTPUT
shell: bash
- name: (debug)
run: |
echo ${{ steps.get-pr-number.outputs.result }}
echo ${{ steps.env-name.outputs.DEPLOYMENT_ID }}
echo ${{ github.run_id }}
- name: start deployment
uses: bobheadxi/deployments@v1
id: start-deployment
with:
step: start
token: ${{ secrets.GH_BOT_TOKEN }}
env: ${{ steps.env-name.outputs.DEPLOYMENT_ID }}
ref: ${{ steps.comment-branch.outputs.head_ref }}
override: true