From 5c1e375d0eb80d27b0e6be7ee307797dd8a7ab3d Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez Date: Mon, 14 Apr 2025 16:40:17 +0200 Subject: [PATCH 1/2] Add replace uuid --- .github/workflows/replace-uuid-generate.yaml | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/replace-uuid-generate.yaml 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 }} From ffbf12a46b89138dd7711d5e3339d7e06c067d73 Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez Date: Mon, 14 Apr 2025 16:40:42 +0200 Subject: [PATCH 2/2] Adding test --- agonzalezrh/test/common.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 agonzalezrh/test/common.yaml 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