-
Notifications
You must be signed in to change notification settings - Fork 193
76 lines (73 loc) · 2.71 KB
/
manual-pull-request-bot.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# This workflow allows maintainers to manually run the PR bot on a pull request to work around permissions
# issues that prevent it from working for non-maintainers.
name: Invoke PR Bot as Maintainer
on:
workflow_dispatch:
inputs:
pull_number:
description: The PR number to invoke the PR bot on.
required: true
type: string
jobs:
get-pr-info:
name: Get PR info
runs-on: ubuntu-latest
steps:
- name: Get PR info
id: get-pr-info
uses: actions/github-script@v6
with:
script: |
const response = await github.rest.pulls.get({
pull_number: ${{ inputs.pull_number }},
owner: context.repo.owner,
repo: context.repo.repo,
});
const data = {
base_revision: response.data.base.sha,
head_revision: response.data.head.sha,
};
console.log("data:", data);
return data;
outputs:
pull_data: ${{ steps.get-pr-info.outputs.result }}
# This job detects if the PR made changes to build tools. If it did, then it builds a new
# build Docker image. Otherwise, it downloads a build image from Public ECR. In both cases,
# it uploads the image as a build artifact for other jobs to download and use.
acquire-base-image:
name: Acquire Base Image
needs:
- get-pr-info
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: smithy-rs
# The ref used needs to match the HEAD revision of the PR being diffed, or else
# the `docker-build` action won't find the built Docker image. This has the unfortunate
# side effect that the codegen diff tool used is the one in the PR rather than in
# the branch this workflow was launched from.
ref: ${{ fromJSON(needs.get-pr-info.outputs.pull_data).head_revision }}
fetch-depth: 0
- name: Acquire base image
id: acquire
run: ./smithy-rs/.github/scripts/acquire-build-image
- name: Upload base image
uses: actions/upload-artifact@v3
with:
name: smithy-rs-base-image
path: smithy-rs-base-image
retention-days: 1
invoke-pr-bot:
name: PR Bot
needs:
- acquire-base-image
- get-pr-info
uses: ./.github/workflows/pull-request-bot.yml
with:
issue_number: ${{ inputs.pull_number }}
base_revision: ${{ fromJSON(needs.get-pr-info.outputs.pull_data).base_revision }}
head_revision: ${{ fromJSON(needs.get-pr-info.outputs.pull_data).head_revision }}
secrets:
SMITHY_RS_PULL_REQUEST_CDN_S3_BUCKET_NAME: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_S3_BUCKET_NAME }}
SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN: ${{ secrets.SMITHY_RS_PULL_REQUEST_CDN_ROLE_ARN }}