Skip to content
Closed

Pr #41

Show file tree
Hide file tree
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
43 changes: 43 additions & 0 deletions .github/workflows/replace-uuid-generate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Replace asset_uuid on PR

on:
pull_request:
types: [opened, synchronize]

jobs:
replace-uuid:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Set up Python (for UUID generation)
uses: actions/setup-python@v5
with:
python-version: 3.x

- name: Generate and replace UUID
id: replace
run: |
FILE="common.yaml"
if grep -q 'asset_uuid: generate' "$FILE"; then
UUID=$(python -c "import uuid; print(uuid.uuid4())")
echo "Replacing with UUID: $UUID"
sed -i "s/asset_uuid: generate/asset_uuid: $UUID/" "$FILE"
echo "uuid=$UUID" >> $GITHUB_OUTPUT
else
echo "No replacement needed."
echo "uuid=none" >> $GITHUB_OUTPUT
fi

- name: Commit and push changes
if: steps.replace.outputs.uuid != 'none'
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git commit -am "Replace asset_uuid: generate with UUID"
git push origin HEAD:${{ github.head_ref }}
3 changes: 3 additions & 0 deletions agonzalezrh/test/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
__meta__:
asset_uuid: generate
Loading