diff --git a/.github/workflows/replace-uuid-generate.yaml b/.github/workflows/replace-uuid-generate.yaml new file mode 100644 index 0000000..cf83341 --- /dev/null +++ b/.github/workflows/replace-uuid-generate.yaml @@ -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 }} diff --git a/agonzalezrh/test/common.yaml b/agonzalezrh/test/common.yaml new file mode 100644 index 0000000..6b655b9 --- /dev/null +++ b/agonzalezrh/test/common.yaml @@ -0,0 +1,3 @@ +--- +__meta__: + asset_uuid: generate