Skip to content

Commit

Permalink
Merge pull request #1 from oarbusi/CLOUDP-242548
Browse files Browse the repository at this point in the history
sign commits and reuse workflow to commit changes
  • Loading branch information
oarbusi authored Apr 16, 2024
2 parents eb01c2d + f64b273 commit 3349fff
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
39 changes: 12 additions & 27 deletions .github/workflows/generate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]
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: '[email protected]'
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
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/run-script-and-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ on:
user_name:
required: true
type: string
secrets:
remote:
required: false

jobs:
run_script_and_commit:
Expand All @@ -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
Expand Down

0 comments on commit 3349fff

Please sign in to comment.