[PROBLEM] agent_deployment_customization inconsistent in documentation #80
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: Backports | |
| # This workflow generates "backport" issues when a release branch label is added to an issue | |
| on: | |
| issues: | |
| types: [labeled] # triggered when any label is added to an issue | |
| env : | |
| TERRAFORM_MAINTAINERS: ${{ vars.TERRAFORM_MAINTAINERS }} # eg. ["matttrach"] | |
| jobs: | |
| create-issue: | |
| runs-on: ubuntu-latest | |
| if: ${{ startsWith(github.event.label.name, 'release/v') }} | |
| steps: | |
| - name: Find and Verify PR Number | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 https://github.com/actions/github-script | |
| id: extract_pr | |
| with: | |
| script: | | |
| const body = context.payload.issue.body; | |
| const regex = /#(\d+)/g; | |
| const matches = body.matchAll(regex); | |
| const potentialNumbers = Array.from(matches, m => m[1]); | |
| for (const number of potentialNumbers) { | |
| try { | |
| const { data: issue } = await github.rest.issues.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: number, | |
| }); | |
| if (issue.pull_request) { | |
| return number; | |
| } | |
| } catch (error) { | |
| // Ignore errors, likely due to some other tag in the issue body. | |
| core.info(`Could not retrieve issue #${number}: ${error.message}`); | |
| } | |
| } | |
| core.setFailed('No valid PR found.'); | |
| - name: Create GitHub Issue | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 https://github.com/actions/github-script | |
| env : | |
| TERRAFORM_MAINTAINERS: ${{env.TERRAFORM_MAINTAINERS}} | |
| PR: ${{ steps.extract_pr.outputs.result }} | |
| with: | |
| script: | | |
| // Checking out the repository is a security risk, so we instead fetch the script content directly | |
| // This allows us to validate the script in code reviews before merging | |
| const response = await github.rest.repos.getContent({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| path: ".github/workflows/scripts/backport-issues.js", | |
| // 'context.sha' is the SHA of the last commit on the default branch for this trigger | |
| ref: context.sha, | |
| }); | |
| const scriptContent = Buffer.from(response.data.content, "base64").toString(); | |
| // The script will be executed in an async context | |
| const script = eval(scriptContent); | |
| await script({github, context, core, process}); |