improve ci job names, rewrite deploy yaml
All checks were successful
Update Community Skins README / Full CI/CD Pipeline (push) Successful in 10s
All checks were successful
Update Community Skins README / Full CI/CD Pipeline (push) Successful in 10s
This commit is contained in:
@@ -11,7 +11,7 @@ env:
|
|||||||
GITEA_API: https://${{ vars.CONTAINER_REGISTRY }}/api/v1
|
GITEA_API: https://${{ vars.CONTAINER_REGISTRY }}/api/v1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
generate_everything:
|
update_community_skins_readme:
|
||||||
name: Full CI/CD Pipeline
|
name: Full CI/CD Pipeline
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Sync CI from skins-template to Every User Repository
|
name: Update Community Skins CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -10,22 +10,24 @@ env:
|
|||||||
IMAGE_NAME: osc/skins-image
|
IMAGE_NAME: osc/skins-image
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sync-all:
|
update_ci_for_all_users:
|
||||||
|
name: Sync CI Template to All Skin Repositories
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
image: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch CI template via Gitea API
|
- name: Mask Sensitive Tokens
|
||||||
shell: bash
|
run: echo "::add-mask::$TOKEN"
|
||||||
|
|
||||||
|
- name: Fetch CI Template from skins-template
|
||||||
run: |
|
run: |
|
||||||
resp=$(curl -sSL -H "Authorization: token $TOKEN" \
|
resp=$(curl -sSL -H "Authorization: token $TOKEN" \
|
||||||
"$GITEA_API/repos/osc/skins-template/contents/$TEMPLATE_PATH?ref=main")
|
"$GITEA_API/repos/osc/skins-template/contents/$TEMPLATE_PATH?ref=main")
|
||||||
template_b64=$(echo "$resp" | jq -r .content)
|
template_b64=$(echo "$resp" | jq -r .content)
|
||||||
echo "TEMPLATE_B64=$template_b64" >> $GITHUB_ENV
|
echo "TEMPLATE_B64=$template_b64" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Fetch valid user repositories
|
- name: Find Repositories with Skins Directory
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
page=1
|
page=1
|
||||||
per_page=50
|
per_page=50
|
||||||
@@ -42,88 +44,61 @@ jobs:
|
|||||||
|
|
||||||
for i in $(seq 0 $((users_count - 1))); do
|
for i in $(seq 0 $((users_count - 1))); do
|
||||||
user_login=$(echo "$users_json" | jq -r ".[$i].login")
|
user_login=$(echo "$users_json" | jq -r ".[$i].login")
|
||||||
echo "[$user_counter/$user_count_total] Processing user: $user_login"
|
echo "[$user_counter/$user_count_total] User: $user_login"
|
||||||
repos_json=$(curl -sSL -H "Authorization: token $TOKEN" \
|
repos_json=$(curl -sSL -H "Authorization: token $TOKEN" \
|
||||||
"$GITEA_API/users/$user_login/repos")
|
"$GITEA_API/users/$user_login/repos")
|
||||||
repo_count=$(echo "$repos_json" | jq 'length')
|
repo_count=$(echo "$repos_json" | jq 'length')
|
||||||
|
|
||||||
if [ "$repo_count" -ne 0 ]; then
|
|
||||||
repo_matched=false
|
|
||||||
for j in $(seq 0 $((repo_count - 1))); do
|
for j in $(seq 0 $((repo_count - 1))); do
|
||||||
owner=$(echo "$repos_json" | jq -r ".[$j].owner.login")
|
owner=$(echo "$repos_json" | jq -r ".[$j].owner.login")
|
||||||
repo=$(echo "$repos_json" | jq -r ".[$j].name")
|
repo=$(echo "$repos_json" | jq -r ".[$j].name")
|
||||||
|
|
||||||
contents=$(curl -sSL -H "Authorization: token $TOKEN" \
|
contents=$(curl -sSL -H "Authorization: token $TOKEN" \
|
||||||
"$GITEA_API/repos/$owner/$repo/contents?ref=main")
|
"$GITEA_API/repos/$owner/$repo/contents?ref=main")
|
||||||
if echo "$contents" | jq -e '.[] | select(.type=="dir" and .name=="Skins")' >/dev/null; then
|
if echo "$contents" | jq -e '.[] | select(.type=="dir" and .name=="Skins")' >/dev/null; then
|
||||||
echo "$owner/$repo" >> "$valid_repos_file"
|
echo "$owner/$repo" >> "$valid_repos_file"
|
||||||
echo "added $owner/$repo"
|
echo "✔️ Found valid repo: $owner/$repo"
|
||||||
repo_matched=true
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
[ "$repo_matched" = false ] && echo "no matching repos for $user_login"
|
|
||||||
else
|
|
||||||
echo "no repos for $user_login"
|
|
||||||
fi
|
|
||||||
|
|
||||||
user_counter=$((user_counter + 1))
|
user_counter=$((user_counter + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
page=$((page + 1))
|
page=$((page + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "VALID_REPOS_FILE=$valid_repos_file" >> $GITHUB_ENV
|
echo "VALID_REPOS_FILE=$valid_repos_file" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Update CI via Gitea API
|
- name: Apply CI Template to Valid Repositories
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
set -eo pipefail
|
|
||||||
mapfile -t repos < "$VALID_REPOS_FILE"
|
mapfile -t repos < "$VALID_REPOS_FILE"
|
||||||
for repo_full in "${repos[@]}"; do
|
for repo_full in "${repos[@]}"; do
|
||||||
owner=${repo_full%%/*}
|
owner=${repo_full%%/*}
|
||||||
repo=${repo_full##*/}
|
repo=${repo_full##*/}
|
||||||
api="$GITEA_API/repos/$owner/$repo"
|
api="$GITEA_API/repos/$owner/$repo"
|
||||||
|
|
||||||
default_branch=$(curl -sSL --fail -H "Authorization: token $TOKEN" \
|
default_branch=$(curl -sSL -H "Authorization: token $TOKEN" "$api" | jq -r '.default_branch')
|
||||||
"$api" | jq -r '.default_branch')
|
latest_tag=$(curl -sSL -H "Authorization: token $TOKEN" "$api/tags" | jq -r '.[0].name // empty')
|
||||||
|
|
||||||
latest_tag=$(curl -sSL --fail -H "Authorization: token $TOKEN" \
|
|
||||||
"$api/tags" | jq -r '.[0].name // empty')
|
|
||||||
|
|
||||||
url="$api/contents/$TEMPLATE_PATH"
|
url="$api/contents/$TEMPLATE_PATH"
|
||||||
sha=$(curl -sSL -H "Authorization: token $TOKEN" "$url" \
|
sha=$(curl -sSL -H "Authorization: token $TOKEN" "$url" | jq -r '.sha // empty' || true)
|
||||||
| jq -r 'select(.sha != null).sha // empty' || true)
|
|
||||||
|
|
||||||
if [[ -z "$sha" ]]; then
|
if [[ -z "$sha" ]]; then
|
||||||
action="Add"
|
action="Add"
|
||||||
msg="Add CI from skins-template"
|
msg="Add CI from skins-template"
|
||||||
payload=$(jq -nc \
|
payload=$(jq -nc --arg message "$msg" --arg content "$TEMPLATE_B64" --arg branch "$default_branch" \
|
||||||
--arg message "$msg" \
|
|
||||||
--arg content "$TEMPLATE_B64" \
|
|
||||||
--arg branch "$default_branch" \
|
|
||||||
'{message: $message, content: $content, branch: $branch}')
|
'{message: $message, content: $content, branch: $branch}')
|
||||||
else
|
else
|
||||||
action="Update"
|
action="Update"
|
||||||
msg="Update CI from skins-template"
|
msg="Update CI from skins-template"
|
||||||
payload=$(jq -nc \
|
payload=$(jq -nc --arg message "$msg" --arg content "$TEMPLATE_B64" --arg sha "$sha" --arg branch "$default_branch" \
|
||||||
--arg message "$msg" \
|
|
||||||
--arg content "$TEMPLATE_B64" \
|
|
||||||
--arg sha "$sha" \
|
|
||||||
--arg branch "$default_branch" \
|
|
||||||
'{message: $message, content: $content, sha: $sha, branch: $branch}')
|
'{message: $message, content: $content, sha: $sha, branch: $branch}')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if curl -sSL --fail -X PUT \
|
if curl -sSL --fail -X PUT -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||||
-H "Authorization: token $TOKEN" \
|
-d "$payload" "$url" >/dev/null; then
|
||||||
-H "Content-Type: application/json" \
|
echo "✅ $action successful for $owner/$repo on branch $default_branch"
|
||||||
-d "$payload" \
|
|
||||||
"$url" >/dev/null; then
|
|
||||||
echo "✅ $action $owner/$repo on branch $default_branch"
|
|
||||||
else
|
else
|
||||||
echo "❌ $action failed for $owner/$repo → $url" >&2
|
echo "❌ $action failed for $owner/$repo" >&2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup Temporary Files
|
||||||
shell: bash
|
|
||||||
run: rm -f "$VALID_REPOS_FILE"
|
run: rm -f "$VALID_REPOS_FILE"
|
||||||
|
|||||||
Reference in New Issue
Block a user