Skip to content

Commit cde0159

Browse files
committed
remove deployments (notify with comments again)
1 parent ea29d1c commit cde0159

File tree

2 files changed

+122
-62
lines changed

2 files changed

+122
-62
lines changed

.github/workflows/pull-request-preview-cleanup.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,33 @@ jobs:
8181
# body: "removed the deployment on <https://liputenpotest-${{ github.event.number }}.surge.sh>"
8282
# env:
8383
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
84+
85+
- name: Find Comment
86+
uses: peter-evans/find-comment@v1
87+
id: fc
88+
with:
89+
issue-number: ${{ github.event.pull_request.number }}
90+
comment-author: "github-actions[bot]"
91+
body-includes: "surge: "
92+
env:
93+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
94+
95+
- name: Create comment
96+
if: steps.fc.outputs.comment-id == ''
97+
uses: peter-evans/create-or-update-comment@v1
98+
with:
99+
issue-number: ${{ github.event.pull_request.number }}
100+
body: |
101+
surge: removed the deployment on <https://liputenpotest-${{ github.event.number }}.surge.sh>
102+
env:
103+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
104+
105+
- name: Update comment
106+
if: steps.fc.outputs.comment-id != ''
107+
uses: peter-evans/create-or-update-comment@v1
108+
with:
109+
comment-id: ${{ steps.fc.outputs.comment-id }}
110+
body: |
111+
surge: removed the deployment on <https://liputenpotest-${{ github.event.number }}.surge.sh>
112+
env:
113+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/pull-request-preview.yml

Lines changed: 92 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626

2727
permissions:
2828
contents: read
29-
deployments: write
29+
# deployments: write
3030
pull-requests: write
3131
statuses: write
3232
issues: write
@@ -35,41 +35,41 @@ jobs:
3535
deploy:
3636
runs-on: ubuntu-latest
3737
steps:
38-
- name: get pull request ref
39-
id: get_pull_request_ref
40-
uses: octokit/[email protected]
41-
with:
42-
route: GET /repos/:repository/pulls/:issue_id
43-
repository: ${{ github.repository }}
44-
issue_id: ${{ github.event.number }}
45-
env:
46-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
38+
# - name: get pull request ref
39+
# id: get_pull_request_ref
40+
# uses: octokit/[email protected]
41+
# with:
42+
# route: GET /repos/:repository/pulls/:issue_id
43+
# repository: ${{ github.repository }}
44+
# issue_id: ${{ github.event.number }}
45+
# env:
46+
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
4747

48-
- name: create deployment
49-
id: create_deployment
50-
uses: octokit/[email protected]
51-
with:
52-
route: POST /repos/:repository/deployments
53-
repository: ${{ github.repository }}
54-
ref: ${{ github.event.pull_request.base.ref }}
55-
environment: dev
56-
auto_merge: false
57-
required_contexts: "[]"
58-
env:
59-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
48+
# - name: create deployment
49+
# id: create_deployment
50+
# uses: octokit/[email protected]
51+
# with:
52+
# route: POST /repos/:repository/deployments
53+
# repository: ${{ github.repository }}
54+
# ref: ${{ github.event.pull_request.base.ref }}
55+
# environment: dev
56+
# auto_merge: false
57+
# required_contexts: "[]"
58+
# env:
59+
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
6060

61-
- name: set deployment status to in progress
62-
id: start_deployment
63-
uses: octokit/[email protected]
64-
with:
65-
route: POST /repos/:repository/deployments/:deployment/statuses
66-
repository: ${{ github.repository }}
67-
deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }}
68-
environment: dev
69-
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
70-
state: in_progress
71-
env:
72-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
61+
# - name: set deployment status to in progress
62+
# id: start_deployment
63+
# uses: octokit/[email protected]
64+
# with:
65+
# route: POST /repos/:repository/deployments/:deployment/statuses
66+
# repository: ${{ github.repository }}
67+
# deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }}
68+
# environment: dev
69+
# log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
70+
# state: in_progress
71+
# env:
72+
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
7373

7474
# deployment goes here
7575
- name: Checkout
@@ -87,35 +87,35 @@ jobs:
8787
- name: Remove pdfs (filesize restraints)
8888
run: rm _site/pdfs/*.pdf
8989
- name: deploy to surge
90-
run: npm run surge -- --token "${{ secrets.SURGE_TOKEN }}" --domain liputenpotest-${{ github.event.number }}.surge.sh
90+
run: npm run surge -- --token "${{ secrets.SURGE_TOKEN }}" --domain liputenpotest-${{ github.event.number }}.surge.sh
9191

92-
- name: set deployment status to success
93-
id: successful_deployment
94-
uses: octokit/[email protected]
95-
with:
96-
route: POST /repos/:repository/deployments/:deployment/statuses
97-
repository: ${{ github.repository }}
98-
deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }}
99-
environment: dev
100-
environment_url: https://liputenpotest-${{ github.event.number }}.surge.sh
101-
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
102-
state: success
103-
env:
104-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
92+
# - name: set deployment status to success
93+
# id: successful_deployment
94+
# uses: octokit/[email protected]
95+
# with:
96+
# route: POST /repos/:repository/deployments/:deployment/statuses
97+
# repository: ${{ github.repository }}
98+
# deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }}
99+
# environment: dev
100+
# environment_url: https://liputenpotest-${{ github.event.number }}.surge.sh
101+
# log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
102+
# state: success
103+
# env:
104+
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
105105

106-
- name: set deployment status to failure
107-
id: failed_deployment
108-
uses: octokit/[email protected]
109-
if: failure()
110-
with:
111-
route: POST /repos/:repository/deployments/:deployment/statuses
112-
repository: ${{ github.repository }}
113-
deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }}
114-
environment: dev
115-
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
116-
state: failure
117-
env:
118-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
106+
# - name: set deployment status to failure
107+
# id: failed_deployment
108+
# uses: octokit/[email protected]
109+
# if: failure()
110+
# with:
111+
# route: POST /repos/:repository/deployments/:deployment/statuses
112+
# repository: ${{ github.repository }}
113+
# deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }}
114+
# environment: dev
115+
# log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
116+
# state: failure
117+
# env:
118+
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
119119

120120
# - name: Send confirmation
121121
# id: send_confirmation
@@ -124,6 +124,36 @@ jobs:
124124
# route: POST /repos/:repository/issues/:issue_id/comments
125125
# repository: ${{ github.repository }}
126126
# issue_id: ${{ github.event.number }}
127-
# body: "deployed to <https://liputenpotest-${{ github.event.number }}.surge.sh>"
127+
# body: "surge: deployed to <https://liputenpotest-${{ github.event.number }}.surge.sh>"
128128
# env:
129129
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
130+
131+
- name: Find Comment
132+
uses: peter-evans/find-comment@v1
133+
id: fc
134+
with:
135+
issue-number: ${{ github.event.pull_request.number }}
136+
comment-author: "github-actions[bot]"
137+
body-includes: "surge: "
138+
env:
139+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
140+
141+
- name: Create comment
142+
if: steps.fc.outputs.comment-id == ''
143+
uses: peter-evans/create-or-update-comment@v1
144+
with:
145+
issue-number: ${{ github.event.pull_request.number }}
146+
body: |
147+
surge: deployed to <https://liputenpotest-${{ github.event.number }}.surge.sh>
148+
env:
149+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
150+
151+
- name: Update comment
152+
if: steps.fc.outputs.comment-id != ''
153+
uses: peter-evans/create-or-update-comment@v1
154+
with:
155+
comment-id: ${{ steps.fc.outputs.comment-id }}
156+
body: |
157+
surge: deployed to <https://liputenpotest-${{ github.event.number }}.surge.sh>
158+
env:
159+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

0 commit comments

Comments
 (0)