Update .gitea/workflows/deploy-ci.yaml
All checks were successful
Update Community Skins README / gather-skins (push) Successful in 10s
Update Community Skins README / generate-readme (push) Successful in 3s
Update Community Skins README / commit-readme (push) Successful in 2s

This commit is contained in:
Arlind
2025-07-04 16:13:10 +02:00
parent 5dc27991eb
commit 9edf999273

View File

@@ -12,12 +12,13 @@ env:
jobs: jobs:
fetch-template: fetch-template:
name: Fetch CI Template name: Fetch CI Template and .gitattributes
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
outputs: outputs:
template_b64: ${{ steps.load-template.outputs.template_b64 }} template_b64: ${{ steps.load-template.outputs.template_b64 }}
gitattributes_b64: ${{ steps.load-gitattributes.outputs.gitattributes_b64 }}
steps: steps:
- name: Mask Sensitive Token - name: Mask Sensitive Token
@@ -30,11 +31,21 @@ jobs:
echo "📥 Fetching template from osc/skins-template@$TEMPLATE_PATH" echo "📥 Fetching template from osc/skins-template@$TEMPLATE_PATH"
resp=$(curl -sSL -H "Authorization: token ${{ secrets.TOKEN }}" \ resp=$(curl -sSL -H "Authorization: token ${{ secrets.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 fetched and encoded" echo "✅ Template fetched and encoded"
echo "template_b64=$template_b64" >> $GITHUB_OUTPUT echo "template_b64=$template_b64" >> $GITHUB_OUTPUT
- id: load-gitattributes
name: Load .gitattributes from osc/skins-template
run: |
set -eo pipefail
echo "📥 Fetching .gitattributes from osc/skins-template"
resp=$(curl -sSL -H "Authorization: token ${{ secrets.TOKEN }}" \
"$GITEA_API/repos/osc/skins-template/contents/.gitattributes?ref=main")
gitattributes_b64=$(echo "$resp" | jq -r .content)
echo "✅ .gitattributes fetched and encoded"
echo "gitattributes_b64=$gitattributes_b64" >> $GITHUB_OUTPUT
discover-repositories: discover-repositories:
name: Discover Valid Skin Repositories name: Discover Valid Skin Repositories
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -100,7 +111,7 @@ jobs:
retention-days: 1 retention-days: 1
sync-template: sync-template:
name: Sync CI Template name: Sync CI Template and .gitattributes
needs: [fetch-template, discover-repositories] needs: [fetch-template, discover-repositories]
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
@@ -118,7 +129,7 @@ jobs:
echo "🗂️ Repositories to process:" echo "🗂️ Repositories to process:"
cat "${{ env.REPO_LIST_FILE }}" cat "${{ env.REPO_LIST_FILE }}"
- name: Apply Template to Repositories - name: Apply Template and .gitattributes to Repositories
shell: bash shell: bash
run: | run: |
set -eo pipefail set -eo pipefail
@@ -128,31 +139,39 @@ jobs:
owner="${repo_full%%/*}" owner="${repo_full%%/*}"
repo="${repo_full##*/}" repo="${repo_full##*/}"
api="$GITEA_API/repos/$owner/$repo" api="$GITEA_API/repos/$owner/$repo"
echo "🔧 Syncing CI and .gitattributes to: $owner/$repo"
echo "🔧 Syncing CI to: $owner/$repo"
default_branch=$(curl -sSL -H "Authorization: token ${{ secrets.TOKEN }}" "$api" | jq -r '.default_branch') default_branch=$(curl -sSL -H "Authorization: token ${{ secrets.TOKEN }}" "$api" | jq -r '.default_branch')
url="$api/contents/$TEMPLATE_PATH"
sha=$(curl -sSL -H "Authorization: token ${{ secrets.TOKEN }}" "$url" | jq -r '.sha // empty' || true)
if [[ -z "$sha" ]]; then for file in "$TEMPLATE_PATH" ".gitattributes"; do
action="Add" if [[ "$file" == "$TEMPLATE_PATH" ]]; then
msg="Add CI from skins-template" content="${{ needs.fetch-template.outputs.template_b64 }}"
payload=$(jq -nc --arg message "$msg" --arg content "${{ needs.fetch-template.outputs.template_b64 }}" --arg branch "$default_branch" \ msg="Update CI from skins-template"
'{message: $message, content: $content, branch: $branch}') else
else content="${{ needs.fetch-template.outputs.gitattributes_b64 }}"
action="Update" msg="Update .gitattributes from skins-template"
msg="Update CI from skins-template" fi
payload=$(jq -nc --arg message "$msg" --arg content "${{ needs.fetch-template.outputs.template_b64 }}" --arg sha "$sha" --arg branch "$default_branch" \
'{message: $message, content: $content, sha: $sha, branch: $branch}')
fi
if curl -sSL --fail -X PUT -H "Authorization: token ${{ secrets.TOKEN }}" -H "Content-Type: application/json" \ url="$api/contents/$file"
-d "$payload" "$url" >/dev/null; then sha=$(curl -sSL -H "Authorization: token ${{ secrets.TOKEN }}" "$url" | jq -r '.sha // empty' || true)
echo "✅ $action successful for $owner/$repo on branch $default_branch"
else if [[ -z "$sha" ]]; then
echo "❌ $action failed for $owner/$repo" >&2 action="Add"
fi payload=$(jq -nc --arg message "$msg" --arg content "$content" --arg branch "$default_branch" \
'{message: $message, content: $content, branch: $branch}')
else
action="Update"
payload=$(jq -nc --arg message "$msg" --arg content "$content" --arg sha "$sha" --arg branch "$default_branch" \
'{message: $message, content: $content, sha: $sha, branch: $branch}')
fi
if curl -sSL --fail -X PUT -H "Authorization: token ${{ secrets.TOKEN }}" -H "Content-Type: application/json" \
-d "$payload" "$url" >/dev/null; then
echo "✅ $action successful for $file in $owner/$repo"
else
echo "❌ $action failed for $file in $owner/$repo" >&2
fi
done
done done
- name: Cleanup - name: Cleanup