forked from oven-sh/bun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add comment when updating a submodule
- Loading branch information
1 parent
2f0789a
commit 5573b2e
Showing
1 changed file
with
87 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,87 @@ | ||
name: Comment on updated submodule | ||
|
||
permissions: | ||
issues: write | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "src/generated_versions_list.zig" | ||
- ".github/workflows/on-submodule-update.yml" | ||
|
||
jobs: | ||
comment: | ||
name: Comment | ||
runs-on: ubuntu-latest | ||
if: ${{ github.repository_owner == 'oven-sh' }} | ||
steps: | ||
- name: Checkout current | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
sparse-checkout: | | ||
src/generated_versions_list.zig | ||
- name: Hash generated versions list | ||
id: hash | ||
run: | | ||
echo "hash=$(sha256sum src/generated_versions_list.zig | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT | ||
- name: Checkout base | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.base.sha }} | ||
sparse-checkout: | | ||
src/generated_versions_list.zig | ||
- name: Hash base | ||
id: base | ||
run: | | ||
echo "base=$(sha256sum src/generated_versions_list.zig | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT | ||
- name: Compare | ||
id: compare | ||
run: | | ||
if [ "${{ steps.hash.outputs.hash }}" != "${{ steps.base.outputs.base }}" ]; then | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "changed=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Find Comment | ||
id: comment | ||
uses: peter-evans/find-comment@v3 | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: github-actions[bot] | ||
body-includes: <!-- generated-comment submodule-updated --> | ||
- name: Write Warning Comment | ||
uses: peter-evans/create-or-update-comment@v4 | ||
if: steps.compare.outputs.changed == 'true' | ||
with: | ||
comment-id: ${{ steps.comment.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
edit-mode: replace | ||
body: | | ||
⚠️ **Warning:** @${{ github.actor }} has updated submodules. If this was intentional, please ignore this message. If not, please undo changes to submodules and rebase your branch. | ||
<!-- generated-comment submodule-updated --> | ||
- name: Add labels | ||
uses: actions-cool/issues-helper@v3 | ||
if: steps.compare.outputs.changed == 'true' | ||
with: | ||
actions: "add-labels" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
labels: "updated-submodule" | ||
- name: Remove labels | ||
uses: actions-cool/issues-helper@v3 | ||
if: steps.compare.outputs.changed == 'false' | ||
with: | ||
actions: "remove-labels" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
labels: "updated-submodule" | ||
- name: Delete outdated comment | ||
uses: actions-cool/issues-helper@v3 | ||
if: steps.compare.outputs.changed == 'false' && steps.comment.outputs.comment-id != '' | ||
with: | ||
actions: "delete-comment" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-id: ${{ steps.comment.outputs.comment-id }} |