Skip to content

Create config_docs workflow #22

Create config_docs workflow

Create config_docs workflow #22

Workflow file for this run

name: Update Config Docs
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
env:
BRANCH_NAME: ruby-config-updates
DESTINATION_REPO: kaylareopelle/docs-website
jobs:
regenerate_config_docs:
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- name: Install Ruby 3.2
uses: ruby/setup-ruby@7d546f4868fb108ed378764d873683f920672ae2 # tag v1.149.0
with:
ruby-version: 3.2
- name: Checkout code
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # tag v3.5.0
- run: bundle
- name: Generate config doc
run: bundle exec rake newrelic:config:docs[html]
- name: Create branch
uses: dmnemec/copy_file_to_another_repo_action@c93037aa10fa8893de271f19978c980d0c1a9b37 # tag v1.1.1
env:
API_TOKEN_GITHUB: ${{ secrets.KAYLA_CONFIG_DOCS }}
with:
source_file: "ruby-agent-configuration.mdx"
destination_repo: ${{ env.DESTINATION_REPO }}
destination_folder: 'src/content/docs/apm/agents/ruby-agent/configuration'
user_email: '${{ secrets.EMAIL }}'
user_name: 'newrelic-ruby-agent-bot'
destination_branch: 'develop'
destination_branch_create: ${{ env.BRANCH_NAME }}
commit_message: 'chore(ruby agent): Update config docs'
check_diff_for_changes:
runs-on: ubuntu-22.04
needs: [regenerate_config_docs]
steps:
- name: Checkout code
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # tag v3.5.0
with:
repository: ${{ env.DESTINATION_REPO }}
ref: ${{ env.BRANCH_NAME }}
token: ${{ secrets.KAYLA_CONFIG_DOCS }}
- name: Check diff
run: |
git diff --quiet src/content/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration.mdx && exit 0
create_pull_request:
runs-on: ubuntu-22.04
needs: [regenerate_config_docs, check_diff_for_changes]
if: success()
permissions:
pull-requests: write
steps:
- name: Create PR
run: gh pr create --base "develop" --repo "$REPO" --head "$HEAD" --title "$TITLE" --body "$BODY"
env:
GH_TOKEN: ${{ secrets.KAYLA_CONFIG_DOCS }}
REPO: "https://github.com/${{ env.DESTINATION_REPO }}"
HEAD: "${{ env.BRANCH_NAME }}"
TITLE: "Ruby configuration docs test"
BODY: "This is an automated PR generated by the Ruby agent CI. Please delete the branch on merge."
delete_branch_on_fail:
name: Delete branch on fail
needs: [regenerate_config_docs]
runs-on: ubuntu-22.04
if: failure()
steps:
- name: Checkout agent repository
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # tag v3.5.0
- name: Checkout docs website repository
uses: actions/checkout@v3
with:
repository: ${{ env.DESTINATION_REPO }}
token: ${{ secrets.KAYLA_CONFIG_DOCS }}
- 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 }}