-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Tugboat webhook integration with Tugboat API in GHA workflows
- Loading branch information
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Delete Tugboat Preview | ||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
paths-ignore: | ||
- '**.md' | ||
|
||
jobs: | ||
tugboat_delete_preview: | ||
runs-on: self-hosted | ||
env: | ||
NODE_EXTRA_CA_CERTS: /etc/ssl/certs/ca-certificates.crt | ||
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: | | ||
if ! [ -f .tugboat_preview.txt ]; then | ||
echo "Preview ID not found, please manually delete Tugboat Preview." | ||
exit 1 | ||
fi | ||
PREVIEW_ID=$(cat .tugboat_preview.txt) | ||
echo "Preview ID: ${PREVIEW_ID}" | ||
echo "PREVIEW_ID=$PREVIEW_ID" >> $GITHUB_ENV | ||
- name: Cleanup temporary file | ||
run: rm .tugboat_preview.txt | ||
- name: Delete Tugboat Preview | ||
run: | | ||
curl -H "Authorization: Bearer ${{ secrets.TUGBOAT_API_TOKEN }}" \ | ||
-H "Content-Type: application/json" \ | ||
-X DELETE \ | ||
-d '{ "force": "false" }' \ | ||
https://api.tugboat.vfs.va.gov/v3/previews/${{ env.PREVIEW_ID }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Create Tugboat Preview | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
paths-ignore: | ||
- '**.md' | ||
|
||
jobs: | ||
tugboat_create_preview: | ||
runs-on: self-hosted | ||
env: | ||
NODE_EXTRA_CA_CERTS: /etc/ssl/certs/ca-certificates.crt | ||
name: Create Tugboat Preview | ||
steps: | ||
- name: Create Tugboat Preview | ||
id: tugboat_pr_preview | ||
run: | | ||
curl -H "Authorization: Bearer ${{ secrets.TUGBOAT_API_TOKEN }}" \ | ||
-H "Content-Type: application/json" \ | ||
-X POST \ | ||
-d '{ "repo": "${{ secrets.TUGBOAT_REPOSITORY }}", "ref": "${{ github.event.pull_request.number }}", "name": "${{ github.event.pull_request.title }}", "type": "pullrequest" }' \ | ||
-o .tugboat_response.json \ | ||
https://api.tugboat.vfs.va.gov/v3/previews | ||
- name: Diagnostics | ||
run: cat .tugboat_response.json | ||
- name: Extract Preview ID | ||
run: jq -r .preview .tugboat_response.json > .tugboat_preview.txt | ||
- 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 | ||
key: ${{ runner.os }}-tugboat-preview-id-pr-${{ github.event.pull_request.number }} | ||
- name: Cleanup temporary file | ||
run: rm .tugboat_preview.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Rebuild Tugboat Preview | ||
on: | ||
pull_request: | ||
types: | ||
- synchronize | ||
paths-ignore: | ||
- '**.md' | ||
|
||
jobs: | ||
tugboat_rebuild_preview: | ||
runs-on: self-hosted | ||
env: | ||
NODE_EXTRA_CA_CERTS: /etc/ssl/certs/ca-certificates.crt | ||
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: | | ||
if ! [ -f .tugboat_preview.txt ]; then | ||
echo "Preview ID not found, please manually rebuild Tugboat Preview." | ||
exit 1 | ||
fi | ||
PREVIEW_ID=$(cat .tugboat_preview.txt) | ||
echo "Preview ID: ${PREVIEW_ID}" | ||
echo "PREVIEW_ID=$PREVIEW_ID" >> $GITHUB_ENV | ||
- name: Cleanup temporary file | ||
run: rm .tugboat_preview.txt | ||
- name: Rebuild Tugboat Preview | ||
run: | | ||
curl -H "Authorization: Bearer ${{ secrets.TUGBOAT_API_TOKEN }}" \ | ||
-H "Content-Type: application/json" \ | ||
-X POST \ | ||
-d '{ "children": "false", "force": "false" }' \ | ||
https://api.tugboat.vfs.va.gov/v3/previews/${{ env.PREVIEW_ID }}/rebuild |