Skip to content

Commit 85f3499

Browse files
authored
chore: workflow to automatically request a deployment to the test-pipeline (#26496)
Creates a workflow that will request a GitHub Environment deployment whenever cli files change. The deployment has to be approved by a team member to run. The actual code to deploy is just a push to the `test-main-pipeline` branch, thus reusing the existing functionality. Workflow tested on my fork. When change has been detected: <img width="883" alt="image" src="https://github.com/aws/aws-cdk/assets/379814/8b7951ec-0256-4ebf-ac60-39b82ab6a712"> After approval: <img width="874" alt="image" src="https://github.com/aws/aws-cdk/assets/379814/6f3ce6f1-9c3b-44b3-bbfb-d0804c18f9dc"> After request submitted: <img width="949" alt="image" src="https://github.com/aws/aws-cdk/assets/379814/47920d0e-4a78-4a90-8be8-031ab0480d6b"> ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e53e8dc commit 85f3499

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Request a deployment to the test pipeline
2+
3+
name: request-cli-integ-test
4+
on:
5+
pull_request_target: {}
6+
7+
jobs:
8+
cli-changes:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
any-changed-files: ${{ steps.changed-cli-files.outputs.cli_any_changed }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
ref: ${{ github.event.pull_request.head.ref }}
17+
repository: ${{ github.event.pull_request.head.repo.full_name }}
18+
fetch-depth: 0
19+
persist-credentials: false
20+
- name: Find changed cli files
21+
id: changed-cli-files
22+
uses: tj-actions/changed-files@v37
23+
with:
24+
files_yaml: |
25+
cli:
26+
- packages/aws-cdk/bin/**
27+
- packages/aws-cdk/lib/**
28+
- packages/aws-cdk/test/**
29+
submit-to-test-pipeline:
30+
environment: test-pipeline
31+
needs: cli-changes
32+
if: needs.cli-changes.outputs.any-changed-files == 'true'
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v3
37+
with:
38+
ref: ${{ github.event.pull_request.head.ref }}
39+
repository: ${{ github.event.pull_request.head.repo.full_name }}
40+
- name: Submit to test-pipeline
41+
# Needs to run with PROJEN_GITHUB_TOKEN because we need permissions to force push the branch
42+
run: |
43+
git config --global user.name 'aws-cdk-automation'
44+
git config --global user.email '[email protected]'
45+
git push --force --atomic https://oauth2:${{ secrets.PROJEN_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git FETCH_HEAD:test-main-pipeline
46+
- name: Explain next steps
47+
uses: thollander/actions-comment-pull-request@v2
48+
with:
49+
message: |
50+
:arrow_right: **PR build request submitted to `test-main-pipeline`** :arrow_left:
51+
52+
A maintainer must now manually check the pipeline and add the `pr-linter/cli-integ-tested` label once the pipeline succeeds.
53+
comment_tag: request-cli-integ-test
54+
mode: recreate
55+
# Post as our automation user
56+
GITHUB_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }}

0 commit comments

Comments
 (0)