Skip to content

Commit

Permalink
Add update/close workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
JunTaoLuo committed Dec 7, 2023
1 parent d5b9390 commit e47c053
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/tugboat-pr-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Delete Tugboat Preview
on:
pull_request:
types:
- closed

jobs:
tugboat_delete_preview:
runs-on: self-hosted
name: Delete Tugboat Preview
steps:
- name: Restore Preview ID
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: .tugboat_preview.txt
key: ${{ runner.os }}-tugboat-preview-id-pr-${{ github.event.pull_request.number }}
- name: Set Preview ID
run: |
PREVIEW_ID=$(cat .tugboat_preview.txt)
echo $PREVIEW_ID
echo "PREVIEW_ID=$PREVIEW_ID" >> $GITHUB_ENV
- name: Delete Tugboat Preview
run: |
curl -H "Authorization: Bearer ${{ secrets.TUGBOAT_API_TOKEN }}" \
-H "Content-Type: application/json" \
-X DELETE \
https://api.tugboat.vfs.va.gov/v3/previews/${{ env.PREVIEW_ID }}
8 changes: 7 additions & 1 deletion .github/workflows/tugboat-pr-opened.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
types:
- opened
- reopened

jobs:
tugboat_create_preview:
Expand All @@ -22,7 +23,12 @@ jobs:
run: cat .tugboat_response.json
- name: Extract Preview ID
run: jq -r .preview .tugboat_response.json > .tugboat_preview.txt
- name: Save Preview ID
- name: Delete Previous Preview ID
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "${{ runner.os }}-tugboat-preview-id-pr-${{ github.event.pull_request.number }}" --confirm
- name: Save Preview ID
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: .tugboat_preview.txt
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/tugboat-pr-updated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Rebuild Tugboat Preview
on:
pull_request:
types:
- synchronize

jobs:
tugboat_rebuild_preview:
runs-on: self-hosted
name: Rebuild Tugboat Preview
steps:
- name: Restore Preview ID
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: .tugboat_preview.txt
key: ${{ runner.os }}-tugboat-preview-id-pr-${{ github.event.pull_request.number }}
- name: Set Preview ID
run: |
PREVIEW_ID=$(cat .tugboat_preview.txt)
echo $PREVIEW_ID
echo "PREVIEW_ID=$PREVIEW_ID" >> $GITHUB_ENV
- name: Rebuild Tugboat Preview
run: |
curl -H "Authorization: Bearer ${{ secrets.TUGBOAT_API_TOKEN }}" \
-H "Content-Type: application/json" \
-X POST \
https://api.tugboat.vfs.va.gov/v3/previews/${{ env.PREVIEW_ID }}/rebuild

0 comments on commit e47c053

Please sign in to comment.