Skip to content

Commit

Permalink
Do not load submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
mkirilin committed Mar 25, 2024
1 parent 2a8bafd commit f4224d4
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/ci_submodule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
jobs:

linux-sub:
permissions: write-all
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
env:
Expand All @@ -15,15 +16,15 @@ jobs:
- name: Checkout source code for base
uses: actions/checkout@v4
with:
submodules: true
submodules: false
path: base

- name: Checkout source code for head
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
submodules: true
submodules: false
path: head

- name: Determine hashes to compare
Expand All @@ -32,28 +33,28 @@ jobs:
EVENT_PATH="${GITHUB_EVENT_PATH}"
cd "${GITHUB_WORKSPACE}" \
|| error "__Line:${LINENO}__Error: Cannot change directory to Github Workspace"
echo "PR=`jq -r ".number" "${EVENT_PATH}"`" >> $GITHUB_ENV
PR=`jq -r ".number" "${EVENT_PATH}"`
PR_BRANCH=`jq -r ".pull_request.head.ref" "${EVENT_PATH}"`
BASE_BRANCH=`jq -r ".pull_request.base.ref" "${EVENT_PATH}"`
echo "Run for PR of ${PR_BRANCH} into ${BASE_BRANCH}"
cd head
git fetch origin "${PR_BRANCH}" --recurse-submodules=no \
|| error "__Line:${LINENO}__Error: Could not fetch history of ${PR_BRANCH}"
HEAD_SC_HASH=`git log -n1 sc | awk 'NR==1{ print $2 }'`
cd ../base
git fetch origin "${BASE_BRANCH}" --recurse-submodules=no \
|| error "__Line:${LINENO}__Error: Could not fetch history of ${BASE_BRANCH}"
cd ..
- name: Convert PR to draft if necessary
shell: bash
run: |
CHANGED=`git diff --name-only --no-index -- "${GITHUB_WORKSPACE}"/base/ "${GITHUB_WORKSPACE}"/head/` || true
if grep "^${INPUT_PATH}$" <<< "${CHANGED}"; then
BASE_SC_HASH=`git log -n1 sc | awk 'NR==1{ print $2 }'`
echo "HEAD_SC_HASH: $HEAD_SC_HASH, BASE_SC_HASH: $BASE_SC_HASH"
if [[ "x$HEAD_SC_HASH"!="x$BASE_SC_HASH" ]]; then
echo "${TOKEN}" | gh auth login --with-token
echo "Login successfully with token ${TOKEN}."
echo "PR: $PR"
gh pr comment ${PR} --body \
"Submodule has been changed by this PR. \
This is forbidden by the repository policy. \
Your PR is turned into a draft PR."
echo "PR was commented successfully."
gh api graphql -F id="${PR_NODE_ID}" -f query='
mutation($id: ID!) {
convertPullRequestToDraft(input: { pullRequestId: $id }) {
Expand Down

0 comments on commit f4224d4

Please sign in to comment.