-
Notifications
You must be signed in to change notification settings - Fork 14
41 lines (40 loc) · 1.37 KB
/
stage-pr.yaml
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
name: Deploy PR Branch
on:
issue_comment:
types: [created]
jobs:
trigger-pr-branch-deploy:
runs-on: ubuntu-latest
permissions:
actions: write
if: github.event.issue.pull_request && github.event.issue.state == 'open' && github.event.comment.body == '/deploy'
steps:
- name: Get Pull Request Head Ref
id: get-head-ref
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const response = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
console.log(response.data)
return response.data.head.ref
- name: Trigger a Branch Deploy
uses: actions/github-script@v6
with:
script: |
const response = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "deploy.yaml",
ref: "${{ steps.get-head-ref.outputs.result }}",
inputs: {
"aws-env": `github-actions-course-demo-pr-${context.issue.number}`,
"github-env": "staging",
"report-pr": `${context.issue.number}`
}
})
console.log(response)