Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and enhance mirror-update-warning action #1425

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 28 additions & 21 deletions .github/workflows/mirror-update-warning.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
name: mirror-update-warning
name: Mirror update notification

on: push
on:
pull_request:
branches:
- master
paths:
- backend_modules/libvirt/base/main.tf

jobs:
Check-changed-files:
check-image-urls:
name: Check updated image URLs
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v2
- name: Get Changed Files
id: get_file_changes
uses: trilom/[email protected]
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
plaintext: true
- name: RESULTS
fetch-depth: 2
- name: Find modified image URLs
run: |
for directory in ${{ steps.get_file_changes.outputs.files }}
do
if [ ${directory} == "backend_modules/libvirt/base/main.tf" ]
then
echo "IMAGES_CHANGED=true" >> $GITHUB_ENV
fi
done
- name: PR Comment
if: env.IMAGES_CHANGED == 'true'
uses: peter-evans/commit-comment@v1
echo "IMAGE_LIST<<EOF" >> $GITHUB_ENV

git diff -p -U0 --no-color --diff-filter=M -G"\{var\.mirror\}" \
${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} \
-- backend_modules/libvirt/base/main.tf | \
grep "^[+-] " | sed 's/^[+-]\s*\([^ ]*\).*$/ - `\1`/' | uniq >> $GITHUB_ENV

echo "EOF" >> $GITHUB_ENV
- name: Comment on the pull request
uses: actions-cool/maintain-one-comment@v3
with:
delete: ${{ !env.IMAGE_LIST }}
body: |
Before merging this PR, keep in mind we must have updated CI and BV Mirror YAML files.
Thank you for your collaboration.
This pull request updates the URLs of the following images:
${{ env.IMAGE_LIST }}

Please consider updating the CI and BV mirror configurations accordingly.
Loading