diff --git a/.changelog/2140.txt b/.changelog/2140.txt new file mode 100644 index 0000000000..81685de87f --- /dev/null +++ b/.changelog/2140.txt @@ -0,0 +1,3 @@ +```release-note:test +test: changelog change test +``` diff --git a/.github/workflows/generate-changelog.yml b/.github/workflows/generate-changelog.yml index daed041168..77815e0c4c 100644 --- a/.github/workflows/generate-changelog.yml +++ b/.github/workflows/generate-changelog.yml @@ -7,36 +7,21 @@ on: - .changelog/** workflow_dispatch: jobs: - generate-changelog: + generate-and-update-changelog: if: github.event.pull_request.merged || github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - with: - fetch-depth: 0 - persist-credentials: false - - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 - with: - go-version-file: 'go.mod' - - run: make tools update-changelog-unreleased-section - - run: | - if [[ $(git status --porcelain) ]]; then - if ${{github.event_name == 'workflow_dispatch'}}; then - MSG="Update CHANGELOG.md (Manual Trigger)" - else - MSG="Update CHANGELOG.md for #${{ github.event.pull_request.number }}" - fi - git config --local user.email changelogbot@mongodb.com - git config --local user.name changelogbot - git remote set-url origin https://svc-apix-bot:${{ secrets.APIX_BOT_PAT }}@github.com/${{ github.repository }} - git add CHANGELOG.md - git commit -m "$MSG" - git push - fi + uses: ./.github/workflows/run-script-and-commit.yml + with: + script_call: 'make tools update-changelog-unreleased-section' + file_to_commit: 'CHANGELOG.md' + commit_message: ${{ github.event_name == 'workflow_dispatch' && 'Update CHANGELOG.md (Manual Trigger)' || format('{0}{1}', 'Update CHANGELOG.md for \#', github.event.pull_request.number) }} + user_email: 'svc-api-experience-integrations-escalation@mongodb.com' + user_name: 'svc-apix-bot' + secrets: + remote: https://svc-apix-bot:${{ secrets.APIX_BOT_PAT }}@github.com/${{ github.repository }} slack-notification: - needs: [generate-changelog] - if: ${{ !cancelled() && needs.generate-changelog.result == 'failure' }} + needs: [generate-and-update-changelog] + if: ${{ !cancelled() && needs.generate-and-update-changelog.result == 'failure' }} runs-on: ubuntu-latest steps: - name: Send Slack message diff --git a/.github/workflows/run-script-and-commit.yml b/.github/workflows/run-script-and-commit.yml index 304f710447..52f0aab2ff 100644 --- a/.github/workflows/run-script-and-commit.yml +++ b/.github/workflows/run-script-and-commit.yml @@ -19,6 +19,9 @@ on: user_name: required: true type: string + secrets: + remote: + required: false jobs: run_script_and_commit: @@ -32,12 +35,25 @@ jobs: - name: Run specified script run: ${{ inputs.script_call }} + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v2 + with: + git_user_signingkey: true + git_commit_gpgsign: true + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.PASSPHRASE }} + - name: Commit changes run: | if [[ $(git status --porcelain) ]]; then git pull git config --local user.email ${{ inputs.user_email }} git config --local user.name ${{ inputs.user_name }} + if ${{ secrets.remote != '' }}; then + git remote set-url origin ${{ secrets.remote }} + fi git add ${{ inputs.file_to_commit }} git commit -m "${{ inputs.commit_message }}" git push