From 36f486259f7dd395db83aa1352e2f59c812cea5e Mon Sep 17 00:00:00 2001 From: zhijie-yang Date: Tue, 3 Dec 2024 11:31:00 +0100 Subject: [PATCH 1/2] fix(ci): add escapes for [ and ] to allow renovatebot trigger mock-rock (#301) * fix(ci): add escapes for [ and ] to allow renovate[bot] trigger mock-rock * ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/12129562961 * chore(action/validate-actor): use temp file to expand CODEOWNER teams * ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/12137581597 --------- Co-authored-by: zhijie-yang --- .github/actions/validate-actor/validate-actor.sh | 11 ++++++----- oci/mock-rock/_releases.json | 14 +++++++------- oci/mock-rock/contacts.yaml | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/actions/validate-actor/validate-actor.sh b/.github/actions/validate-actor/validate-actor.sh index da2401b4..ad663d69 100755 --- a/.github/actions/validate-actor/validate-actor.sh +++ b/.github/actions/validate-actor/validate-actor.sh @@ -6,22 +6,24 @@ workspace=$3 image_path=$4 echo "github.actor: ${actor}" +actor=$(echo "$actor" | sed 's/\[/\\[/g;s/\]/\\]/g') # Escape square brackets for actors like renovate[bot] echo "admin-only: ${admin_only}" if [[ ${admin_only} == true ]]; then exit_status=0 echo "Expanding team mentions in the CODEOWNERS file" - cp ${workspace}/CODEOWNERS ${workspace}/CODEOWNERS.bak - teams=$(grep -oE '@[[:alnum:]_.-]+\/[[:alnum:]_.-]+' ${workspace}/CODEOWNERS || true | sort | uniq) + codeowners_file=$(mktemp) + cp ${workspace}/CODEOWNERS ${codeowners_file} + teams=$(grep -oE '@[[:alnum:]_.-]+\/[[:alnum:]_.-]+' ${codeowners_file} || true | sort | uniq) for team in ${teams}; do org=$(echo ${team} | cut -d'/' -f1 | sed 's/@//') team_name=$(echo ${team} | cut -d'/' -f2) members=$(gh api "/orgs/${org}/teams/${team_name}/members" | jq -r '.[].login') replacement=$(echo "${members}" | xargs -I {} echo -n "@{} " | awk '{$1=$1};1') - sed -i "s|${team}|${replacement}|g" ${workspace}/CODEOWNERS + sed -i "s|${team}|${replacement}|g" ${codeowners_file} done - if grep -wq "@${actor}" ${workspace}/CODEOWNERS; then + if grep -wq "@${actor}" ${codeowners_file}; then echo "The workflow is triggered by ${actor} as the code owner" elif cat ${workspace}/${image_path}/contacts.yaml | yq ".maintainers" | grep "\- " | grep -wq "${actor}"; then echo "The workflow is triggered by ${actor} as a maintainer of the image ${image_path}" @@ -29,7 +31,6 @@ if [[ ${admin_only} == true ]]; then echo "The workflow is triggered by a user neither as a code owner nor a maintainer of the image ${image_path}" exit_status=1 fi - mv ${workspace}/CODEOWNERS.bak ${workspace}/CODEOWNERS exit ${exit_status} else echo "The workflow is not restricted to non-code-owner or non-maintainer users" diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index 20adc658..c63c5449 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2030-05-01T00:00:00Z", "candidate": { - "target": "921" + "target": "948" }, "beta": { - "target": "921" + "target": "948" }, "edge": { - "target": "921" + "target": "948" } }, "1-22.04": { "end-of-life": "2030-05-01T00:00:00Z", "candidate": { - "target": "921" + "target": "948" }, "beta": { - "target": "921" + "target": "948" }, "edge": { - "target": "921" + "target": "948" } }, "1.2-22.04": { "end-of-life": "2030-05-01T00:00:00Z", "beta": { - "target": "922" + "target": "949" }, "edge": { "target": "1.2-22.04_beta" diff --git a/oci/mock-rock/contacts.yaml b/oci/mock-rock/contacts.yaml index 880e30c3..03849420 100644 --- a/oci/mock-rock/contacts.yaml +++ b/oci/mock-rock/contacts.yaml @@ -11,7 +11,7 @@ notify: - fbdezwkcxpfofpysjore1wpfoc maintainers: - - cjdc + - cjdcordeiro - clay-lake - linostar - rebornplusplus From e8490f6e9fce84a28b427568faecd15428067276 Mon Sep 17 00:00:00 2001 From: zhijie-yang Date: Tue, 3 Dec 2024 10:42:15 +0000 Subject: [PATCH 2/2] ci: automatically update oci/mock-rock/_releases.json, from https://github.com/canonical/oci-factory/actions/runs/12137773539 --- oci/mock-rock/_releases.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/oci/mock-rock/_releases.json b/oci/mock-rock/_releases.json index c63c5449..6a0ecdad 100644 --- a/oci/mock-rock/_releases.json +++ b/oci/mock-rock/_releases.json @@ -35,31 +35,31 @@ "1.1-22.04": { "end-of-life": "2030-05-01T00:00:00Z", "candidate": { - "target": "948" + "target": "951" }, "beta": { - "target": "948" + "target": "951" }, "edge": { - "target": "948" + "target": "951" } }, "1-22.04": { "end-of-life": "2030-05-01T00:00:00Z", "candidate": { - "target": "948" + "target": "951" }, "beta": { - "target": "948" + "target": "951" }, "edge": { - "target": "948" + "target": "951" } }, "1.2-22.04": { "end-of-life": "2030-05-01T00:00:00Z", "beta": { - "target": "949" + "target": "952" }, "edge": { "target": "1.2-22.04_beta"