Skip to content

Readme

Readme #11

Workflow file for this run

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)