From 3bab2c4b1c1474632f783c808f2820dba81113a6 Mon Sep 17 00:00:00 2001 From: Mikkel Jakobsen Date: Mon, 3 Jun 2024 14:25:08 +0200 Subject: [PATCH 1/2] Adding package name concept --- .github/workflows/create-pr.yml | 45 ++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/.github/workflows/create-pr.yml b/.github/workflows/create-pr.yml index 39b392fef..6a8371552 100644 --- a/.github/workflows/create-pr.yml +++ b/.github/workflows/create-pr.yml @@ -17,29 +17,32 @@ jobs: steps: - name: Verify Event and set env env: - BUILD_URL: ${{ github.event.client_payload.build_url }} PR_BRANCH: ${{ github.event.client_payload.branch }} PACKAGE: ${{ github.event.client_payload.dependency_package }} run: | + PACKAGE_NAME=$(echo "${{ github.event.client_payload.dependency_package }}" | sed 's/[^\/]*\///') echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_ENV - echo "BUILD_URL=$BUILD_URL" >> $GITHUB_ENV echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV + echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV - BUILD_URL_IS_ACCEPTED=$(echo '${{ vars.ACCEPTED_BUILD_URL_PREFIXES }}' | jq --arg url "${{ env.BUILD_URL }}" 'any(.[]; . as $prefix | $url | contains($prefix))') - echo "BUILD_URL_IS_ACCEPTED=$BUILD_URL_IS_ACCEPTED" >> $GITHUB_ENV - if: ${{ github.event.action == 'create_pr' && github.event.client_payload.branch && github.event.client_payload.build_url && github.event.client_payload.dependency_package }} + PACKAGE_NAME_IS_VALID=$(echo '${{ vars.ACCEPTED_PACKAGES }}' | jq --arg project "${{ env.PACKAGE }}" 'any(.[]; . as $name | $project | match($name))') + echo "PACKAGE_NAME_IS_VALID=$PACKAGE_NAME_IS_VALID" >> $GITHUB_ENV + + echo $PACKAGE_NAME + echo $PACKAGE_NAME_IS_VALID + if: ${{ github.event.action == 'create_pr' && github.event.client_payload.branch && github.event.client_payload.dependency_package }} - name: Stop workflow if any variables are missing run: | echo "::error::Some variable is missing. Have to stop..." exit 1 - if: ${{ !env.PR_BRANCH || !env.BUILD_URL && !env.PACKAGE || !vars.ACCEPTED_BUILD_URL_PREFIXES }} + if: ${{ !env.PR_BRANCH || !env.PACKAGE || !env.PACKAGE_NAME}} - - name: Stop workflow if build url is not valid + - name: Stop workflow if package name is not valid run: | - echo "::error::The build URL is not valid. Should match one of the accepted prefixes." + echo "::error::The package name is not valid. Should match one of the accepted package names." exit 1 - if: ${{ env.BUILD_URL_IS_ACCEPTED != 'true' }} + if: ${{ env.PACKAGE_NAME_IS_VALID != 'true' }} - uses: actions/checkout@v4 with: @@ -56,15 +59,33 @@ jobs: exit 1 if: ${{ steps.check_branch_exists.outputs.exists == 'true' }} + - name: Install go-task + uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Insert dependency id: manipulate_composer run: | set -e - composer config repositories.${{ env.PACKAGE }} '{"type":"package","package":{"name":"${{ env.PACKAGE }}","version":"dev-master","type":"drupal-library","dist":{"url":"${{ env.BUILD_URL }}","type":"zip"},"require":{"composer\/installers":"^1.2.0"}}}' - composer remove ${{ env.PACKAGE }} \ - && composer require ${{ env.PACKAGE }} + declare -a CMDS=( + [poc-dpl-react-pr-trigger]='dev:composer:update-design-system' + [poc-dpl-design-system-pr-trigger]='dev:composer:update-react' + ) + + + COMMAND=${CMDS[$PACKAGE_NAME]} + + if [[ -n "${COMMAND}" ]]; then + task $COMMAND + else + echo "::error::Could not resolve composer task command." + exit 1 + fi + env: + BRANCH: ${{ env.PR_BRANCH }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create branch id: create_branch From aa9d493a752ff48ebc6ec0f666480a0cd4c1503a Mon Sep 17 00:00:00 2001 From: spaceo Date: Mon, 3 Jun 2024 13:39:49 +0000 Subject: [PATCH 2/2] Insert new reference to dependency reload/poc-dpl-react-pr-trigger: --- composer.json | 6 +++--- composer.lock | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 2255af3ea..fbf557f9b 100644 --- a/composer.json +++ b/composer.json @@ -40,10 +40,10 @@ "type": "package", "package": { "name": "danskernesdigitalebibliotek/dpl-react", - "version": "2024.20.1", + "version": "0.0.0-dev", "type": "drupal-library", "dist": { - "url": "https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/2024.20.1/dist-2024-20-1-4291024f5b2d30ec59a5a51497c5f776dd1fda7e.zip", + "url": "https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/branch-DDFLSBP-59-design-ux-ikon-til-burgermenu-valg-som-listeikon/dist-ddflsbp-59-design-ux-ikon-til-burgermenu-valg-som-listeikon.zip", "type": "zip" }, "require": { @@ -89,7 +89,7 @@ "cweagans/composer-patches": "1.7.3", "danskernesdigitalebibliotek/cms-api": "*", "danskernesdigitalebibliotek/dpl-design-system": "2024.20.1", - "danskernesdigitalebibliotek/dpl-react": "2024.20.1", + "danskernesdigitalebibliotek/dpl-react": "0.0.0-dev", "danskernesdigitalebibliotek/fbs-client": "*", "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", "deoliveiralucas/array-keys-case-transform": "^1.1", diff --git a/composer.lock b/composer.lock index 459a0476b..b58d4cffb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ac6f0f0f7a95237c8621dfd0fab4cfae", + "content-hash": "41c0aa079b6ed6dc2ae9bae5a246be42", "packages": [ { "name": "amazeeio/drupal_integrations", @@ -1158,10 +1158,10 @@ }, { "name": "danskernesdigitalebibliotek/dpl-react", - "version": "2024.20.1", + "version": "0.0.0-dev", "dist": { "type": "zip", - "url": "https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/2024.20.1/dist-2024-20-1-4291024f5b2d30ec59a5a51497c5f776dd1fda7e.zip" + "url": "https://github.com/danskernesdigitalebibliotek/dpl-react/releases/download/branch-DDFLSBP-59-design-ux-ikon-til-burgermenu-valg-som-listeikon/dist-ddflsbp-59-design-ux-ikon-til-burgermenu-valg-som-listeikon.zip" }, "require": { "composer/installers": "^1.2.0" @@ -18482,6 +18482,7 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { + "danskernesdigitalebibliotek/dpl-react": 20, "drupal/default_content": 15, "drupal/gin": 5, "drupal/gin_toolbar": 5,