Update .gitea/workflows/ci.yml
This commit is contained in:
@@ -11,8 +11,7 @@ env:
|
|||||||
GITEA_API: https://${{ vars.CONTAINER_REGISTRY }}/api/v1
|
GITEA_API: https://${{ vars.CONTAINER_REGISTRY }}/api/v1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update_community_skins_readme:
|
gather-skins:
|
||||||
name: Full CI/CD Pipeline
|
|
||||||
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
|
||||||
@@ -28,21 +27,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
token: ${{ secrets.TOKEN }}
|
token: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
- name: Pull latest changes
|
- name: Find Skin Repositories and Generate Tables
|
||||||
run: |
|
|
||||||
git fetch origin main
|
|
||||||
git rebase origin/main || {
|
|
||||||
echo "⚠️ Git rebase failed, likely due to conflicts."
|
|
||||||
git rebase --abort || true
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Find Skin Repositories for all users
|
|
||||||
id: find_skins
|
|
||||||
run: |
|
run: |
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
user_rows_file=$(mktemp)
|
mkdir -p data
|
||||||
avatar_rows_file=$(mktemp)
|
user_rows_file=data/user_rows.txt
|
||||||
|
avatar_rows_file=data/avatar_rows.txt
|
||||||
total_valid_entries=0
|
total_valid_entries=0
|
||||||
|
|
||||||
page=1
|
page=1
|
||||||
@@ -103,24 +93,34 @@ jobs:
|
|||||||
page=$((page + 1))
|
page=$((page + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "user_rows_file=$user_rows_file" >> "$GITHUB_OUTPUT"
|
- name: Upload artifacts
|
||||||
echo "avatar_rows_file=$avatar_rows_file" >> "$GITHUB_OUTPUT"
|
uses: actions/upload-artifact@v3
|
||||||
echo "total_valid_entries=$total_valid_entries" >> "$GITHUB_OUTPUT"
|
with:
|
||||||
|
name: skin-tables
|
||||||
|
path: data/
|
||||||
|
|
||||||
- name: Update README with user skins
|
generate-readme:
|
||||||
|
needs: gather-skins
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download skin data
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: skin-tables
|
||||||
|
path: data/
|
||||||
|
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
|
- name: Generate README
|
||||||
run: |
|
run: |
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
README_PATH="${{ env.README_PATH }}"
|
README_PATH="${{ env.README_PATH }}"
|
||||||
user_rows_file="${{ steps.find_skins.outputs.user_rows_file }}"
|
|
||||||
avatar_rows_file="${{ steps.find_skins.outputs.avatar_rows_file }}"
|
|
||||||
total_valid_entries="${{ steps.find_skins.outputs.total_valid_entries }}"
|
|
||||||
|
|
||||||
if [ "$total_valid_entries" -eq 0 ]; then
|
|
||||||
echo "No valid entries found, skipping README update"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp "$README_PATH" "${README_PATH}.bak"
|
cp "$README_PATH" "${README_PATH}.bak"
|
||||||
|
|
||||||
cat > "$README_PATH" <<-EOF
|
cat > "$README_PATH" <<-EOF
|
||||||
@@ -152,7 +152,7 @@ jobs:
|
|||||||
<tbody>
|
<tbody>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sort -t '|' -k1,1n "$user_rows_file" | cut -d'|' -f2- | sed 's/^/ /' >> "$README_PATH"
|
sort -t '|' -k1,1n data/user_rows.txt | cut -d'|' -f2- | sed 's/^/ /' >> "$README_PATH"
|
||||||
|
|
||||||
cat >> "$README_PATH" <<-EOF
|
cat >> "$README_PATH" <<-EOF
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -162,35 +162,55 @@ jobs:
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sort -t '|' -k1,1n "$avatar_rows_file" | cut -d'|' -f2- | sed 's/^/ /' >> "$README_PATH"
|
sort -t '|' -k1,1n data/avatar_rows.txt | cut -d'|' -f2- | sed 's/^/ /' >> "$README_PATH"
|
||||||
|
|
||||||
cat >> "$README_PATH" <<-EOF
|
cat >> "$README_PATH" <<-EOF
|
||||||
</p>
|
</p>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if git diff --quiet "$README_PATH"; then
|
if git diff --quiet "$README_PATH"; then
|
||||||
echo "README has not changed, skipping commit"
|
echo "README has not changed"
|
||||||
rm -f "${README_PATH}.bak"
|
rm -f "${README_PATH}.bak"
|
||||||
exit 0
|
|
||||||
else
|
else
|
||||||
echo "README updated"
|
echo "README updated"
|
||||||
rm -f "${README_PATH}.bak"
|
rm -f "${README_PATH}.bak"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Upload updated README
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: updated-readme
|
||||||
|
path: ${{ env.README_PATH }}
|
||||||
|
|
||||||
|
commit-readme:
|
||||||
|
needs: generate-readme
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download README
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: updated-readme
|
||||||
|
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
- name: Configure Git
|
- name: Configure Git
|
||||||
run: |
|
run: |
|
||||||
git config user.email "arlind@sulej.ch"
|
git config user.email "arlind@sulej.ch"
|
||||||
git config user.name "ci-bot"
|
git config user.name "ci-bot"
|
||||||
git config lfs.https://${{ vars.CONTAINER_REGISTRY }}/arlind/skins.git/info/lfs.locksverify true
|
git config lfs.https://${{ vars.CONTAINER_REGISTRY }}/arlind/skins.git/info/lfs.locksverify true
|
||||||
|
|
||||||
- name: Add and Commit changes
|
- name: Commit and Push README
|
||||||
run: |
|
run: |
|
||||||
git config advice.addIgnoredFile false
|
git config advice.addIgnoredFile false
|
||||||
git add "$README_PATH"
|
git add README.md
|
||||||
git commit -m "[ci skip] push back from pipeline" -q || echo "No changes to commit"
|
git commit -m "[ci skip] push back from pipeline" -q || echo "No changes to commit"
|
||||||
|
|
||||||
- name: Push changes and create tag
|
|
||||||
run: |
|
|
||||||
if [ "${GITHUB_REF}" = "refs/heads/main" ]; then
|
if [ "${GITHUB_REF}" = "refs/heads/main" ]; then
|
||||||
git push origin HEAD:main || echo "No changes to push"
|
git push origin HEAD:main || echo "No changes to push"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user