diff --git a/.backportrc.json b/.backportrc.json new file mode 100644 index 0000000..cd58cc9 --- /dev/null +++ b/.backportrc.json @@ -0,0 +1,14 @@ +{ + "commitConflicts": true, + "targetPRLabels": [ + "backport", + "auto-approve" + ], + "backportBranchName": "backport/{{targetBranch}}-{{refValues}}", + "prTitle": "{{sourcePullRequest.title}} (backport #{{sourcePullRequest.number}})", + "targetBranchChoices": [ + "main", + "v2-main" + ], + "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." +} diff --git a/.gitattributes b/.gitattributes index 2d423b8..1cda09a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,11 +2,13 @@ * text=auto eol=lf *.snap linguist-generated +/.backportrc.json linguist-generated /.eslintrc.json linguist-generated /.gitattributes linguist-generated /.github/pull_request_template.md linguist-generated /.github/workflows/auto-approve.yml linguist-generated /.github/workflows/auto-queue.yml linguist-generated +/.github/workflows/backport.yml linguist-generated /.github/workflows/build.yml linguist-generated /.github/workflows/pull-request-lint.yml linguist-generated /.github/workflows/release-v2-main.yml linguist-generated diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 0000000..cc6531e --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,29 @@ +# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". + +name: backport +on: + pull_request_target: + types: + - labeled + - unlabeled + - closed +jobs: + backport: + name: Backport PR + runs-on: ubuntu-latest + permissions: {} + if: github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport')) + steps: + - name: Check for backport labels + id: check_labels + run: |- + labels='${{ toJSON(github.event.pull_request.labels.*.name) }}' + matched=$(echo $labels | jq '.|map(select(startswith("backport-to-"))) | length') + echo "matched=$matched" + echo "matched=$matched" >> $GITHUB_OUTPUT + - name: Backport Action + if: fromJSON(steps.check_labels.outputs.matched) > 0 + uses: sqren/backport-github-action@v9.5.1 + with: + github_token: ${{ secrets.PROJEN_GITHUB_TOKEN }} + auto_backport_label_prefix: backport-to- diff --git a/.gitignore b/.gitignore index e1649ea..3c8cfae 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,6 @@ junit.xml /lib/**/*.d.ts.map /dist/ !/.eslintrc.json +!/.backportrc.json +!/.github/workflows/backport.yml !/.projenrc.ts diff --git a/.npmignore b/.npmignore index 9965643..c235d2f 100644 --- a/.npmignore +++ b/.npmignore @@ -22,6 +22,7 @@ tsconfig.tsbuildinfo /.eslintrc.json *.ts !*.d.ts +.backportrc.json /.gitattributes /.projenrc.ts /projenrc diff --git a/.projen/files.json b/.projen/files.json index 1374819..4ff43a5 100644 --- a/.projen/files.json +++ b/.projen/files.json @@ -1,10 +1,12 @@ { "files": [ + ".backportrc.json", ".eslintrc.json", ".gitattributes", ".github/pull_request_template.md", ".github/workflows/auto-approve.yml", ".github/workflows/auto-queue.yml", + ".github/workflows/backport.yml", ".github/workflows/build.yml", ".github/workflows/pull-request-lint.yml", ".github/workflows/release-v2-main.yml", diff --git a/.projenrc.ts b/.projenrc.ts index 52af7e7..aeced15 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -1,4 +1,4 @@ -import { typescript } from 'projen'; +import { github, typescript } from 'projen'; const project = new typescript.TypeScriptProject({ name: 'cdk-assets', projenrcTs: true, @@ -140,4 +140,7 @@ project.eslint?.addRules({ '@cdklabs/promiseall-no-unbounded-parallelism': ['error'], }); +// Allow PR backports to all releasable branches +new github.PullRequestBackport(project); + project.synth();