Generate Release Notes #120
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate Release Notes | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
send-pull-requests: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # tag v1.175.1 | |
with: | |
ruby-version: 3.3 | |
- name: Checkout code | |
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag v4.1.2 | |
- name: Generate release notes and environment variables | |
run: | | |
ruby -r $PWD/.github/workflows/scripts/generate_release_notes.rb -e GenerateReleaseNotes.new.write_output_file | |
echo "branch_name=$(ruby -r $PWD/.github/workflows/scripts/generate_release_notes.rb -e GenerateReleaseNotes.new.branch_name)" >> $GITHUB_ENV | |
- name: Build source file | |
run: echo "source_file=$PWD/$(ruby -r $PWD/.github/workflows/scripts/generate_release_notes.rb -e GenerateReleaseNotes.new.file_name)" >> $GITHUB_ENV | |
- name: Create branch | |
uses: dmnemec/copy_file_to_another_repo_action@c93037aa10fa8893de271f19978c980d0c1a9b37 # tag v1.1.1 | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.NEWRELIC_RUBY_AGENT_BOT_TOKEN }} | |
with: | |
source_file: "${{env.source_file}}" | |
destination_repo: 'newrelic/docs-website' | |
destination_folder: 'src/content/docs/release-notes/agent-release-notes/ruby-release-notes' | |
user_email: '${{ secrets.EMAIL }}' | |
user_name: 'newrelic-ruby-agent-bot' | |
destination_branch: 'develop' | |
destination_branch_create: ${{env.branch_name}} | |
commit_message: 'chore(ruby agent): add release notes' | |
- name: Create pull request | |
run: gh pr create --base "develop" --repo "$REPO" --head "$HEAD" --title "$TITLE" --body "$BODY" | |
env: | |
GH_TOKEN: ${{ secrets.NEWRELIC_RUBY_AGENT_BOT_TOKEN }} | |
REPO: https://github.com/newrelic/docs-website/ | |
HEAD: ${{env.branch_name}} | |
TITLE: "Ruby Release Notes" | |
BODY: "This is an automated PR generated when the Ruby agent is released. Please merge as soon as possible." | |
delete_branch_on_fail: | |
name: Delete branch on fail | |
needs: [send-pull-requests] | |
runs-on: ubuntu-22.04 | |
if: failure() | |
steps: | |
- name: Checkout agent repository | |
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag v4.1.2 | |
- name: Get branch name | |
run: echo "branch_name=$(ruby -r $PWD/.github/workflows/scripts/generate_release_notes.rb -e GenerateReleaseNotes.new.branch_name)" >> $GITHUB_ENV | |
- name: Checkout docs website repository | |
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag v4.1.2 | |
with: | |
repository: newrelic/docs-website | |
token: ${{ secrets.NEWRELIC_RUBY_AGENT_BOT_TOKEN }} | |
- name: Build delete command | |
run: echo "delete_file=git push origin --delete ${{env.branch_name}} --force" >> $GITHUB_ENV | |
- name: Delete branch | |
run: ${{env.delete_file}} |