From 745ee55dc9b3fbb3139e1c53ee85adce5424c28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Enrique=20Colina=20Rodr=C3=ADguez?= Date: Tue, 19 Nov 2024 23:45:13 +0100 Subject: [PATCH] fix: Automatic pull request for empty starter fails due to missing issue number in branch name (#30601) (#30707) ### Proposed Changes This pull request introduces a new input parameter to the `cicd_manual_publish-starter.yml` GitHub Actions workflow. The new input parameter, `issue-number`, is used to create the PR branch in case of the empty starter creation. Additionally, it adds a Slack notification step to the workflow. ### Changes 1. **New Input Parameter**: - Introduce a new input parameter `issue-number`. - This parameter is used to create the PR branch in case of the `Empty Starter` creation. 2. **Message Composition**: - Construct a detailed message about the newly published starter. - Include information such as starter type, artifact filename, artifact URL, old assets included, and changelog. - Append the composed message to the GitHub Actions output. 3. **Slack Notification Step**: - Add a new step named "Slack Notification" to the workflow. - Use the custom GitHub Action located at `.github/actions/core-cicd/notification/notify-slack`. - Send a notification to the `log-starter` Slack channel. - Use the composed message as the payload for the Slack notification. - Retrieve the Slack bot token from GitHub Secrets. ### Motivation The addition of the `issue-number` input parameter ensures that the PR branch is correctly created in case of the `Empty Starter` creation. The Slack notification step ensures that team members are promptly informed about new starter publications, improving communication and awareness within the team, and meeting with the Status Check validation on PR branch naming conventions. ### Testing - Verified that the `issue-number` input parameter is correctly handled and used to create the PR branch. - Verified that the message is correctly composed and appended to the GitHub Actions output. - Confirmed that the Slack notification is sent to the specified channel with the correct payload. ### Additional Info This PR resolves #30601 (Automatic pull request for empty starter fails due to missing issue number in branch name). --- .../workflows/cicd_manual_publish-starter.yml | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/.github/workflows/cicd_manual_publish-starter.yml b/.github/workflows/cicd_manual_publish-starter.yml index 649338e9aab9..bde27271338e 100644 --- a/.github/workflows/cicd_manual_publish-starter.yml +++ b/.github/workflows/cicd_manual_publish-starter.yml @@ -12,11 +12,15 @@ on: old-assets: description: 'Include old assets' required: true - type: boolean + type: boolean changelog: description: 'Changes description' required: true type: string + issue-number: + description: 'Related issue number. Required to create Empty Starter PR.' + required: true + type: string dry-run: description: 'Enable dry-run mode' required: true @@ -96,6 +100,7 @@ jobs: outputs: filename: ${{ steps.deploy-artifacts.outputs.filename }} url: ${{ steps.deploy-artifacts.outputs.url }} + pr_created: ${{ steps.create-pull-request.outcome == 'success' }} steps: - uses: jfrog/setup-jfrog-cli@v4 env: @@ -156,41 +161,27 @@ jobs: echo "::notice::Changelog: ${{ github.event.inputs.changelog }}" echo "::endgroup::" - update-pom: - if: ${{ github.event.inputs.type == 'empty' && github.event.inputs.dry-run == 'false' }} - needs: [ deploy-artifacts ] - runs-on: ubuntu-20.04 - environment: starter - outputs: - pull-request-url: ${{ steps.create-pull-request.outputs.pull-request-url }} - steps: - - uses: actions/checkout@v4 - - name: 'Update pom.xml' + if: ${{ github.event.inputs.type == 'empty' && github.event.inputs.dry-run == 'false' }} id: update-pom working-directory: ${{ github.workspace }}/parent env: - FILENAME: ${{ needs.deploy-artifacts.outputs.filename }} + FILENAME: ${{ steps.deploy-artifacts.outputs.filename }} run: | echo "::group::Update pom.xml" echo "Updating pom.xml" - VERSION="${FILENAME%.*}" - - # Create an auxiliary branch for versioning updates - AUXILIARY_BRANCH=update-starter-version-${VERSION}-${{ github.run_id }} - + AUXILIARY_BRANCH=${{ inputs.issue-number }}-update-starter-version-${VERSION}-${{ github.run_id }} sed -i "s/.*<\/starter.deploy.version>/${VERSION}<\/starter.deploy.version>/" pom.xml - POM=$(cat pom.xml) echo "POM file: ${POM}" - echo auxiliary-branch=${AUXILIARY_BRANCH} >> $GITHUB_OUTPUT echo starter-version=${VERSION} >> $GITHUB_OUTPUT echo "::notice::Auxiliary Branch: ${AUXILIARY_BRANCH}" - echo "::endgroup::" + echo "::endgroup::" - name: 'Create Pull Request' + if: ${{ steps.update-pom.outcome == 'success' }} id: create-pull-request uses: peter-evans/create-pull-request@v6 with: @@ -202,8 +193,8 @@ jobs: This PR was created automatically to update the **starter.deploy.version** in pom.xml to [**${{ steps.update-pom.outputs.starter-version }}**]. labels: | empty-starter - automated pr - + automated pr + send-notification: needs: [ deploy-artifacts ] runs-on: ubuntu-20.04