Skip to content

Commit 9c92aaa

Browse files
authored
Delete/restructure (UffizziCloud#51)
* restructure workflow for delete * update comments * make endpoint URLs clickable (?) * give option for alternate update-kubeconfig command in the comments * update if statements to not trigger unnecessary builds during delete * update deletion comment to have the right context * link to download CLI * fix issue number for the comment deletion * find comment that needs to be updated for delete
1 parent 861564e commit 9c92aaa

File tree

1 file changed

+63
-48
lines changed

1 file changed

+63
-48
lines changed

.github/workflows/uffizzi.yml

+63-48
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
build-vote:
1515
name: Build and Push `vote`
1616
runs-on: ubuntu-latest
17-
if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }}
17+
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
1818
outputs:
1919
tags: ${{ steps.meta.outputs.tags }}
2020
steps:
@@ -42,7 +42,7 @@ jobs:
4242
build-worker:
4343
name: Build and Push `worker`
4444
runs-on: ubuntu-latest
45-
if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }}
45+
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
4646
outputs:
4747
tags: ${{ steps.meta.outputs.tags }}
4848
steps:
@@ -70,7 +70,7 @@ jobs:
7070
build-result:
7171
name: Build and Push `result`
7272
runs-on: ubuntu-latest
73-
if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }}
73+
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
7474
outputs:
7575
tags: ${{ steps.meta.outputs.tags }}
7676
steps:
@@ -94,16 +94,15 @@ jobs:
9494
labels: ${{ steps.meta.outputs.labels }}
9595
context: ./result
9696

97-
uffizzi-cluster:
97+
uffizzi-cluster-setup:
9898
needs:
9999
- build-vote
100100
- build-worker
101101
- build-result
102-
if: ${{ github.event_name == 'pull_request' }}
102+
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
103103
runs-on: ubuntu-latest
104104
steps:
105105
- name: Checkout
106-
if: ${{ github.event.action != 'closed' }}
107106
uses: actions/checkout@v3
108107

109108
# Identify comment to be updated
@@ -120,18 +119,18 @@ jobs:
120119
- name: Create or Update Comment with Deployment Notification
121120
id: notification
122121
uses: peter-evans/create-or-update-comment@v2
123-
if: ${{ github.event.action != 'closed' }}
124122
with:
125123
comment-id: ${{ steps.find-comment.outputs.comment-id }}
126124
issue-number: ${{ github.event.pull_request.number }}
127125
body: |
128-
## Uffizzi Ephemeral Cluster Environment Deploying
126+
## Uffizzi Ephemeral Environment - Virtual Cluster
129127
130-
:cloud: ${{ env.EXPECTED_URL }}
128+
:cloud: deploying ...
131129
132130
:gear: Updating now by workflow run [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
133131
134-
${{ inputs.description }}
132+
Download the Uffizzi CLI to interact with the upcoming virtual cluster
133+
https://docs.uffizzi.com/install
135134
edit-mode: replace
136135

137136
- if: ${{ github.event.action != 'closed' }}
@@ -142,44 +141,7 @@ jobs:
142141
cluster-name: pr-${{ github.event.pull_request.number }}
143142
server: https://app.uffizzi.com
144143

145-
- name: Create or Update Comment with Deployment URL
146-
uses: peter-evans/create-or-update-comment@v2
147-
if: ${{ github.event.action != 'closed' }}
148-
with:
149-
comment-id: ${{ steps.notification.outputs.comment-id }}
150-
issue-number: ${{ github.event.pull_request.number }}
151-
body: |
152-
## Uffizzi Ephemeral Cluster Environment
153-
154-
Your cluster `pr-${{ github.event.pull_request.number }}` was successfully created. Learn more about [Uffizzi virtual clusters](https://docs.uffizzi.com/virtual-clusters)
155-
To connect to this cluster, follow these steps:
156-
157-
1. Download and install the Uffizzi CLI
158-
2. Login to Uffizzi: `uffizzi login`
159-
3. Update your kubeconfig: `uffizzi cluster update-kubeconfig --name pr-${{ github.event.pull_request.number }} --kubeconfig=[KUBECONFIG]` , replacing `[KUBECONFIG]` with the path to your kubeconfig file.
160-
After updating your kubeconfig, you can manage your cluster with `kubectl`
161-
edit-mode: replace
162-
163-
- if: ${{ github.event.action == 'closed' }}
164-
name: Delete ucluster
165-
uses: UffizziCloud/cluster-action@main
166-
with:
167-
action: delete
168-
cluster-name: pr-${{ github.event.pull_request.number }}
169-
server: https://app.uffizzi.com
170-
171-
- name: Update Comment with Deletion
172-
uses: peter-evans/create-or-update-comment@v2
173-
if: ${{ github.event.action == 'closed' }}
174-
with:
175-
comment-id: ${{ steps.find-comment.outputs.comment-id }}
176-
issue-number: ${{ env.PR_NUMBER }}
177-
body: |
178-
Uffizzi Cluster `pr-${{ github.event.pull_request.number }}` was deleted.
179-
edit-mode: replace
180-
181144
- name: Kustomize and apply
182-
if: ${{ github.event.action != 'closed' }}
183145
run: |
184146
kustomize edit set image vote-image=${{ needs.build-vote.outputs.tags }}
185147
kustomize edit set image result-image=${{ needs.build-result.outputs.tags }}
@@ -210,4 +172,57 @@ jobs:
210172
211173
echo "Access the vote endpoint at \`pr-${{ github.event.number }}-vote.app.qa-gke.uffizzi.com\`." | tee --append $GITHUB_STEP_SUMMARY
212174
echo "Access the result endpoint at \`pr-${{ github.event.number }}-result.app.qa-gke.uffizzi.com\`." | tee --append $GITHUB_STEP_SUMMARY
213-
175+
176+
- name: Create or Update Comment with Deployment URL
177+
uses: peter-evans/create-or-update-comment@v2
178+
with:
179+
comment-id: ${{ steps.notification.outputs.comment-id }}
180+
issue-number: ${{ github.event.pull_request.number }}
181+
body: |
182+
## Uffizzi Ephemeral Environment - Virtual Cluster
183+
184+
Your cluster `pr-${{ github.event.pull_request.number }}` was successfully created. Learn more about [Uffizzi virtual clusters](https://docs.uffizzi.com/virtual-clusters)
185+
To connect to this cluster, follow these steps:
186+
187+
1. Download and install the Uffizzi CLI from https://docs.uffizzi.com/install
188+
2. Login to Uffizzi: `uffizzi login`
189+
3a. Update your kubeconfig: `uffizzi cluster update-kubeconfig --name pr-${{ github.event.pull_request.number }}`. This command will update your local kubeconfig.
190+
If you want to provide an alternate location follow 3b (the next step) instead.
191+
3b. Update your kubeconfig: `uffizzi cluster update-kubeconfig --name pr-${{ github.event.pull_request.number }} --kubeconfig=[KUBECONFIG]`, replacing `[KUBECONFIG]` with the path to your kubeconfig file.
192+
After updating your kubeconfig, you can manage your cluster with `kubectl`.
193+
194+
Access the vote endpoint at https://pr-${{ github.event.number }}-vote.app.qa-gke.uffizzi.com
195+
Access the result endpoint at https://pr-${{ github.event.number }}-result.app.qa-gke.uffizzi.com
196+
197+
edit-mode: replace
198+
199+
uffizzi-cluster-delete:
200+
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
201+
runs-on: ubuntu-latest
202+
steps:
203+
- name: Delete ucluster
204+
uses: UffizziCloud/cluster-action@main
205+
with:
206+
action: delete
207+
cluster-name: pr-${{ github.event.pull_request.number }}
208+
server: https://app.uffizzi.com
209+
210+
# Identify comment to be updated
211+
- name: Find comment for deployment URL
212+
uses: peter-evans/find-comment@v2
213+
id: find-comment
214+
with:
215+
issue-number: ${{ github.event.pull_request.number }}
216+
comment-author: "github-actions[bot]"
217+
body-includes: pr-${{ github.event.pull_request.number }}
218+
direction: last
219+
220+
- name: Update Comment with Deletion
221+
uses: peter-evans/create-or-update-comment@v2
222+
if: ${{ github.event.action == 'closed' }}
223+
with:
224+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
225+
issue-number: ${{ github.event.pull_request.number }}
226+
body: |
227+
Uffizzi Cluster `pr-${{ github.event.pull_request.number }}` was deleted.
228+
edit-mode: replace

0 commit comments

Comments
 (0)