Update quickstarts #1081
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: Update quickstarts | |
env: | |
THIRD_PARTY_GIT_AUTHOR_EMAIL: [email protected] | |
THIRD_PARTY_GIT_AUTHOR_NAME: nr-opensource-bot | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DRY_RUN: false | |
NEW_RELIC_NO_CONFIG_FILE: true | |
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} | |
NEW_RELIC_APP_NAME: ${{ secrets.NEW_RELIC_APP_NAME }} | |
NEW_RELIC_HOST: staging-collector.newrelic.com | |
NODE_ENV: production | |
on: | |
workflow_run: | |
workflows: ["Submit Gate"] | |
types: | |
- completed | |
jobs: | |
generate-uuid: | |
name: Generate UUID | |
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 UUIDs for quickstarts | |
id: generate-uuids | |
run: cd utils && yarn generate-uuids | |
- 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: 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 }}" | |
# main could have been modified since we checked out, so pull before committing | |
git pull --ff-only origin main | |
git add ./quickstarts/* | |
git diff-index --quiet HEAD ./quickstarts/* || { git commit -m 'chore: generate UUID(s) [skip ci]' && echo "commit=true" >> $GITHUB_ENV; } | |
- 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) | |
get-pr-number: | |
name: Get PR number | |
runs-on: ubuntu-latest | |
outputs: | |
pr-number: ${{ steps.output_pr_number.outputs.pr-number }} | |
steps: | |
- name: Download artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: submit_gate.yml | |
run_id: ${{ github.event.workflow_run.id }} | |
- name: Get PR number | |
id: output_pr_number | |
run: | | |
export PR_NUMBER=$(cat artifact/pr_number_submit.txt) | |
echo "pr-number=$PR_NUMBER" >> $GITHUB_OUTPUT | |
staging: | |
needs: [generate-uuid, get-pr-number] | |
uses: ./.github/workflows/reusable.quickstart_submission.yml | |
with: | |
pr-number: ${{ needs.get-pr-number.outputs.pr-number }} | |
dry-run: false | |
secrets: | |
nr-api-url: ${{ secrets.NR_API_URL_STAGING }} | |
nr-api-token: ${{ secrets.NR_API_TOKEN_STAGING }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
nr-license-key: ${{ secrets.NEW_RELIC_LICENSE_KEY }} | |
production: | |
needs: [staging, get-pr-number] | |
uses: ./.github/workflows/reusable.quickstart_submission.yml | |
with: | |
pr-number: ${{ needs.get-pr-number.outputs.pr-number }} | |
dry-run: false | |
secrets: | |
nr-api-url: ${{ secrets.NR_API_URL }} | |
nr-api-token: ${{ secrets.NR_API_TOKEN }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
nr-license-key: ${{ secrets.NEW_RELIC_LICENSE_KEY }} | |
eu-production: | |
needs: [staging, get-pr-number] | |
uses: ./.github/workflows/reusable.quickstart_submission.yml | |
with: | |
pr-number: ${{ needs.get-pr-number.outputs.pr-number }} | |
dry-run: false | |
secrets: | |
nr-api-url: ${{ secrets.NR_API_URL_EU }} | |
nr-api-token: ${{ secrets.NR_API_TOKEN_EU }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
nr-license-key: ${{ secrets.NEW_RELIC_LICENSE_KEY }} |