Skip to content

Pull in changes from 'upstream' #3

Pull in changes from 'upstream'

Pull in changes from 'upstream' #3

Workflow file for this run

name: Deploy PR branches
on:
pull_request:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_REPO: "research-developer-cloud"
TARGET_OWNER: "ndjones"
WORKFLOW_ID: "branch_deploy.yml"
DEPLOY_URL: "https://ndjones.github.io/research-developer-cloud-docs-branch"
permissions: write-all
jobs:
demo-deploy:
name: Trigger test deployments
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get list of open request branches
id: dev-deps
run: |
branches="$(for pr in $(gh pr list --json headRefName | jq -r '.[].headRefName'); do gh pr checks $pr --required --watch --fail-fast > /dev/null && printf "${pr} "; done)"
echo "info:: title=Open Valid Merge Requests" :: ${branches}
echo "branches=$branches" >> $GITHUB_OUTPUT
- name: Trigger Workflow in Another Repository
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${TARGET_OWNER}/${TARGET_REPO}/dispatches \
-d '{"event_type":"deploy","client_payload":{"pr-branches":"${{ steps.dev-deps.outputs.branches }}"}}'
- name: Wait for Workflow Action
run: |
# Just give a minute or so to deploy
sleep 90
# curl -L \
# -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ secrets.PAT }}" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# https://api.github.com/repos/${TARGET_OWNER}/${TARGET_REPO}/actions/runs/deploy.yml
- name: Post messages open requests
run: |
for pr in ${{ steps.dev-deps.outputs.branches }}; do
msg="Test deployment available at <a href=\"${DEPLOY_URL}/${pr}\">${DEPLOY_URL}/${pr}</a>"
(gh pr comment ${pr} --edit-last --body "${msg}") || (gh pr comment ${pr} --body "${msg}")
echo "::info title=Deploy successful::${DEPLOY_URL}/${pr}"
done