Skip to content

Commit 637f297

Browse files
author
Alvaro Muñoz
committed
Fix missing packs in pr-suites-packs.sh
1 parent 37fad92 commit 637f297

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

.github/scripts/pr-suites-packs.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,44 @@ for file in $(gh pr view "$PR_NUMBER" --json files --jq '.files.[].path'); do
2727
codeql pack create "$LANGUAGE"
2828

2929
# if the version of the pack is changed, comment in the PR
30-
PUBLISHED_VERSION=$(gh api /orgs/githubsecuritylab/packages/container/codeql-"$LANGUAGE"/versions --jq '.[0].metadata.container.tags[0]')
31-
CURRENT_VERSION=$(grep version "$LANGUAGE"/qlpack.yml | awk '{print $2}')
30+
PUBLISHED_VERSION=$(gh api /orgs/githubsecuritylab/packages/container/codeql-"$LANGUAGE"-queries/versions --jq '.[0].metadata.container.tags[0]')
31+
CURRENT_VERSION=$(grep version "$LANGUAGE"/src/qlpack.yml | awk '{print $2}')
3232

3333
if [ "$PUBLISHED_VERSION" != "$CURRENT_VERSION" ]; then
3434
echo "[+] New version of pack detected: $PUBLISHED_VERSION (pub) != $CURRENT_VERSION (cur)"
35+
comment="New version of pack \`githubsecuritylab/codeql-$LANGUAGE-queries\` will be created on merge: \`$PUBLISHED_VERSION\`->\`$CURRENT_VERSION\`"
36+
if [[ ! $(gh pr view "$PR_NUMBER" --json comments --jq '.comments.[].body' | grep "$comment") ]]; then
37+
echo "[+] Commenting on PR"
38+
gh pr comment "$PR_NUMBER" \
39+
--body "$comment"
40+
fi
41+
fi
3542

36-
comment="New version of pack \`githubsecuritylab/codeql-$LANGUAGE\` will be created on merge: \`$PUBLISHED_VERSION\`->\`$CURRENT_VERSION\`"
43+
# Same for the libs pack
44+
PUBLISHED_VERSION=$(gh api /orgs/githubsecuritylab/packages/container/codeql-"$LANGUAGE"-libs/versions --jq '.[0].metadata.container.tags[0]')
45+
CURRENT_VERSION=$(grep version "$LANGUAGE"/lib/qlpack.yml | awk '{print $2}')
3746

47+
if [ "$PUBLISHED_VERSION" != "$CURRENT_VERSION" ]; then
48+
echo "[+] New version of pack detected: $PUBLISHED_VERSION (pub) != $CURRENT_VERSION (cur)"
49+
comment="New version of pack \`githubsecuritylab/codeql-$LANGUAGE-libs\` will be created on merge: \`$PUBLISHED_VERSION\`->\`$CURRENT_VERSION\`"
3850
if [[ ! $(gh pr view "$PR_NUMBER" --json comments --jq '.comments.[].body' | grep "$comment") ]]; then
3951
echo "[+] Commenting on PR"
4052
gh pr comment "$PR_NUMBER" \
4153
--body "$comment"
42-
4354
fi
55+
fi
56+
# Same for the libs extensions pack
57+
PUBLISHED_VERSION=$(gh api /orgs/githubsecuritylab/packages/container/codeql-"$LANGUAGE"-extensions/versions --jq '.[0].metadata.container.tags[0]')
58+
CURRENT_VERSION=$(grep version "$LANGUAGE"/ext/qlpack.yml | awk '{print $2}')
4459

60+
if [ "$PUBLISHED_VERSION" != "$CURRENT_VERSION" ]; then
61+
echo "[+] New version of pack detected: $PUBLISHED_VERSION (pub) != $CURRENT_VERSION (cur)"
62+
comment="New version of pack \`githubsecuritylab/codeql-$LANGUAGE-extensions\` will be created on merge: \`$PUBLISHED_VERSION\`->\`$CURRENT_VERSION\`"
63+
if [[ ! $(gh pr view "$PR_NUMBER" --json comments --jq '.comments.[].body' | grep "$comment") ]]; then
64+
echo "[+] Commenting on PR"
65+
gh pr comment "$PR_NUMBER" \
66+
--body "$comment"
67+
fi
4568
fi
4669

4770
PACK_COMPILED=true

0 commit comments

Comments
 (0)