Skip to content

CI / Dispatch / Check pr #34

CI / Dispatch / Check pr

CI / Dispatch / Check pr #34

name: CI / Dispatch / Check pr
on:
workflow_dispatch:
inputs:
pr_url:
description: "GitHub PR URL (e.g., https://github.com/ORG/REPO/pull/123)"
required: true
type: string
rebel_compiler_version:
description: "Version of rebel-compiler to use (optional)"
required: false
type: string
optimum_rbln_version:
description: "Version of optimum-rbln to use (optional)"
required: false
type: string
permissions:
contents: write
jobs:
sync-and-call:
runs-on: rbln-sw-k8s-general
permissions:
contents: write
outputs:
sync_branch: ${{ steps.push.outputs.sync_branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Parse PR URL to owner/repo/number
id: parse
run: |
set -euo pipefail
PR_URL="${{ inputs.pr_url }}"
if [[ "$PR_URL" =~ github\.com/([^/]+)/([^/]+)/pull/([0-9]+) ]]; then
EXT_OWNER="${BASH_REMATCH[1]}"
EXT_REPO="${BASH_REMATCH[2]}"
PR_NUMBER="${BASH_REMATCH[3]}"
else
echo "Bad PR URL: $PR_URL" >&2; exit 1
fi
echo "EXT_OWNER=$EXT_OWNER" >> $GITHUB_ENV
echo "EXT_REPO=$EXT_REPO" >> $GITHUB_ENV
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Fetch PR head from external repo
run: |
set -euo pipefail
git remote add ext "https://github.com/${EXT_OWNER}/${EXT_REPO}.git"
git fetch --no-tags --depth=1 ext "pull/${PR_NUMBER}/head:pr-${PR_NUMBER}"
git checkout "pr-${PR_NUMBER}"
echo "PR_HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Create & push internal sync branch
id: push
run: |
set -euo pipefail
BRANCH="prsync/pr-${PR_NUMBER}-$(echo $PR_HEAD_SHA | cut -c1-7)"
git branch -f "$BRANCH" "$PR_HEAD_SHA"
git config --unset-all http.https://github.com/.extraheader || true
git remote set-url origin "https://x-access-token:${{ secrets.GIT_PAT }}@github.com/${{ github.repository }}.git"
git remote -v
git config -l | grep -E '^http\.https://github\.com/\.extraheader' || echo "no extraheader"
git push -f origin "$BRANCH"
git remote set-url origin "https://x-access-token:${{ secrets.GIT_PAT }}@github.com/${{ github.repository }}.git"
git push -f origin "$BRANCH"
echo "SYNC_BRANCH=$BRANCH" >> $GITHUB_ENV
echo "sync_branch=$BRANCH" >> "$GITHUB_OUTPUT"
check_code_quaility:
needs: sync-and-call
uses: ./.github/workflows/pre-commit.yml
check_internal_tests:
needs: sync-and-call
uses: ./.github/workflows/rbln_trigger_internal_test.yaml
with:
ref: ${{ needs.sync-and-call.outputs.sync_branch }}
rebel_compiler_version: ${{ inputs.rebel_compiler_version }}
optimum_rbln_version: ${{ inputs.optimum_rbln_version }}
secrets: inherit
cleanup:
runs-on: rbln-sw-k8s-general
needs: [sync-and-call, check_code_quaility, check_internal_tests]
if: always()
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Delete sync branch
run: |
set -euo pipefail
SYNC_BRANCH="${{ needs.sync-and-call.outputs.sync_branch }}"
git config --unset-all http.https://github.com/.extraheader || true
git remote set-url origin "https://x-access-token:${{ secrets.GIT_PAT }}@github.com/${{ github.repository }}.git"
if [ -n "$SYNC_BRANCH" ]; then
echo "Deleting branch: $SYNC_BRANCH"
git push origin --delete "$SYNC_BRANCH" || echo "Branch $SYNC_BRANCH may have already been deleted"
fi