Skip to content

Merge pull request #2107 from bshankararamaya/update-grafana-definition #1361

Merge pull request #2107 from bshankararamaya/update-grafana-definition

Merge pull request #2107 from bshankararamaya/update-grafana-definition #1361

Workflow file for this run

name: Release
on:
push:
branches:
- main
env:
THIRD_PARTY_GIT_AUTHOR_EMAIL: [email protected]
THIRD_PARTY_GIT_AUTHOR_NAME: nr-opensource-bot
jobs:
generate-schema-docs:
name: Generate GraphQL schema documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
ref: "main"
fetch-depth: 0
- name: Setup workspace
uses: './.github/actions/bootstrap'
- name: Generate schema docs for GraphQl
id: generate-schema
env:
NR_API_URL: ${{ secrets.NR_API_URL }}
NR_API_TOKEN: ${{ secrets.NR_API_TOKEN }}
run: cd utils && yarn generate-schema-docs
- name: Commit changes
id: commit-changes
run: |
git config --local user.email "${{ env.THIRD_PARTY_GIT_AUTHOR_EMAIL }}"
git config --local user.name "${{ env.THIRD_PARTY_GIT_AUTHOR_NAME }}"
git add ./docs/*
git diff-index --quiet HEAD ./docs/* || git commit -m 'chore: generate schema documentation [skip ci]'
echo "commit=true" >> $GITHUB_ENV
- name: Temporarily disable branch protections
id: disable-branch-protection
if: always()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
script: |
const result = await github.rest.repos.updateBranchProtection({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
required_status_checks: null,
restrictions: null,
enforce_admins: null,
required_pull_request_reviews: null
})
console.log("Result:", result)
- name: Push Commit
if: env.commit == 'true'
run: git push origin HEAD
- name: Re-enable branch protections
id: enable-branch-protection
if: always()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
script: |
const result = await github.rest.repos.updateBranchProtection({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
required_status_checks: {
strict: true,
contexts: [
'Validation / Image count and extension compliance',
'Validation / Ensure icons exist',
'Validation / Install plan ids exist',
'Validation / Install plan schema compliance',
'Validation / Data source schema compliance',
'Validation / Quickstart id are unique',
'Validation / Validate Quickstart Schema'
]
},
restrictions: {
"users":[],
"teams":[],
"apps":[]
},
enforce_admins: true,
required_pull_request_reviews: {
dismiss_stale_reviews: true,
required_approving_review_count: 1,
dismissal_restrictions: {
users: [],
teams: []
}
}
})
console.log("Result:", result)
generate-third-party-notices:
runs-on: ubuntu-latest
steps:
# Checkout fetch-depth: 2 because there's a check to see if package.json
# was updated, and need at least 2 commits for the check to function properly
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Setup workspace
uses: './.github/actions/bootstrap'
- name: Install OSS CLI
working-directory: ./utils
run: |
yarn global add @newrelic/newrelic-oss-cli
- name: Generate Third Party Notices
id: generate-notices
working-directory: ./utils
run: |
if [ ! -f "third_party_manifest.json" ]; then
echo "::error::third_party_manifest.json is missing. Must generate using the newrelic-oss-cli."
exit 1
fi
# latest commit
LATEST_COMMIT=$(git rev-parse HEAD)
# latest commit where package.json was changed
LAST_CHANGED_COMMIT=$(git log -1 --format=format:%H --full-diff package.json)
if [ $LAST_CHANGED_COMMIT = $LATEST_COMMIT ]; then
git config user.email "${{ env.BOT_EMAIL }}"
git config user.name "${{ env.BOT_NAME }}"
oss third-party manifest
oss third-party notices
git add third_party_manifest.json
git add THIRD_PARTY_NOTICES.md
git commit -m 'chore: update third-party manifest and notices [skip-cd]'
echo "commit=true" >> $GITHUB_ENV
else
echo "No change in package.json, not regenerating third-party notices"
fi