Merge pull request #1127 from newrelic/develop #348
This file contains hidden or 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: Release | |
on: | |
push: | |
branches: | |
- main | |
env: | |
BOT_NAME: svc-docs-eng-opensource-bot | |
BOT_EMAIL: [email protected] | |
jobs: | |
generate-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
# Ensure lerna can do the proper version bump | |
# https://github.com/lerna/lerna/issues/2542 | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Configure NPM | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | |
run: | | |
echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > .npmrc | |
- name: Temporarily disable "required_pull_request_reviews" branch protection | |
id: disable-branch-protection | |
if: always() | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.DOCS_ENG_BOT_TOKEN }} | |
previews: luke-cage-preview | |
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: Lerna Publish | |
env: | |
GIT_AUTHOR_NAME: ${{ env.BOT_NAME }} | |
GIT_AUTHOR_EMAIL: ${{ env.BOT_EMAIL }} | |
GIT_COMMITTER_NAME: ${{ env.BOT_NAME }} | |
GIT_COMMITTER_EMAIL: ${{ env.BOT_EMAIL }} | |
GH_TOKEN: ${{ secrets.DOCS_ENG_BOT_TOKEN }} | |
run: yarn release | |
- name: Re-enable "required_pull_request_reviews" branch protection | |
id: enable-branch-protection | |
if: always() | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.DOCS_ENG_BOT_TOKEN }} | |
previews: luke-cage-preview | |
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: true, | |
required_pull_request_reviews: { | |
required_approving_review_count: 0 | |
} | |
}) | |
console.log("Result:", result) |