Skip to content

Commit

Permalink
fix: Automatic pull request for empty starter fails due to missing is…
Browse files Browse the repository at this point in the history
…sue 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).
  • Loading branch information
dcolina authored Nov 19, 2024
1 parent 2239d1d commit 745ee55
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions .github/workflows/cicd_manual_publish-starter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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>.*<\/starter.deploy.version>/<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:
Expand All @@ -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
Expand Down

0 comments on commit 745ee55

Please sign in to comment.