conditional commit
This commit is contained in:
@@ -9,6 +9,9 @@ env:
|
|||||||
README_PATH: "${{ github.workspace }}/README.md"
|
README_PATH: "${{ github.workspace }}/README.md"
|
||||||
IMAGE_NAME: osc/skins-image
|
IMAGE_NAME: osc/skins-image
|
||||||
GITEA_API: https://${{ vars.CONTAINER_REGISTRY }}/api/v1
|
GITEA_API: https://${{ vars.CONTAINER_REGISTRY }}/api/v1
|
||||||
|
ARTIFACT_PATH: "users"
|
||||||
|
USER_ROWS_FILE: "$ARTIFACT_PATH/user_rows.txt"
|
||||||
|
AVATAR_ROWS_FILE: "$ARTIFACT_PATH/avatar_rows.txt"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
gather-skins:
|
gather-skins:
|
||||||
@@ -17,22 +20,23 @@ jobs:
|
|||||||
image: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
image: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Mask Sensitive Tokens
|
- id: mask-secrets
|
||||||
|
name: Mask Sensitive Tokens
|
||||||
run: |
|
run: |
|
||||||
echo "::add-mask::${{ secrets.TOKEN }}"
|
echo "::add-mask::${{ secrets.TOKEN }}"
|
||||||
echo "::add-mask::${{ secrets.OSUAPIV1 }}"
|
echo "::add-mask::${{ secrets.OSUAPIV1 }}"
|
||||||
|
|
||||||
- name: Checkout Repository
|
- id: checkout-code
|
||||||
|
name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.TOKEN }}
|
token: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
- name: Find Skin Repositories and Generate Tables
|
- id: fetch-skins-data
|
||||||
|
name: Find Skin Repositories and Generate Tables
|
||||||
run: |
|
run: |
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
mkdir -p /data
|
mkdir -p $ARTIFACT_PATH
|
||||||
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
|
||||||
@@ -93,34 +97,39 @@ jobs:
|
|||||||
page=$((page + 1))
|
page=$((page + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Upload artifacts
|
- id: upload-tables
|
||||||
|
name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: skin-tables
|
name: skin-tables
|
||||||
path: /data
|
path: $ARTIFACT_PATH
|
||||||
|
|
||||||
generate-readme:
|
generate-readme:
|
||||||
needs: gather-skins
|
needs: gather-skins
|
||||||
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:
|
||||||
|
readme_changed: ${{ steps.check-readme.outputs.changed }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download skin data
|
- id: download-skin-data
|
||||||
|
name: Download skin data
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: skin-tables
|
name: skin-tables
|
||||||
path: /data
|
path: $ARTIFACT_PATH
|
||||||
|
|
||||||
- name: Checkout Repository
|
- id: checkout-code
|
||||||
|
name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.TOKEN }}
|
token: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
- name: Generate README
|
- id: generate-readme
|
||||||
|
name: Generate README
|
||||||
run: |
|
run: |
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
README_PATH="${{ env.README_PATH }}"
|
|
||||||
cp "$README_PATH" "${README_PATH}.bak"
|
cp "$README_PATH" "${README_PATH}.bak"
|
||||||
|
|
||||||
cat > "$README_PATH" <<-EOF
|
cat > "$README_PATH" <<-EOF
|
||||||
@@ -152,7 +161,7 @@ jobs:
|
|||||||
<tbody>
|
<tbody>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sort -t '|' -k1,1n "/data/user_rows.txt" | cut -d'|' -f2- | sed 's/^/ /' >> "$README_PATH"
|
sort -t '|' -k1,1n "USER_ROWS_FILE" | cut -d'|' -f2- | sed 's/^/ /' >> "$README_PATH"
|
||||||
|
|
||||||
cat >> "$README_PATH" <<-EOF
|
cat >> "$README_PATH" <<-EOF
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -162,21 +171,24 @@ jobs:
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sort -t '|' -k1,1n "/data/avatar_rows.txt" | cut -d'|' -f2- | sed 's/^/ /' >> "$README_PATH"
|
sort -t '|' -k1,1n "AVATAR_ROWS_FILE" | cut -d'|' -f2- | sed 's/^/ /' >> "$README_PATH"
|
||||||
|
|
||||||
cat >> "$README_PATH" <<-EOF
|
cat >> "$README_PATH" <<-EOF
|
||||||
</p>
|
</p>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
- id: check-readme
|
||||||
|
name: Check for README changes
|
||||||
|
run: |
|
||||||
if git diff --quiet "$README_PATH"; then
|
if git diff --quiet "$README_PATH"; then
|
||||||
echo "README has not changed"
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||||
rm -f "${README_PATH}.bak"
|
|
||||||
else
|
else
|
||||||
echo "README updated"
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
rm -f "${README_PATH}.bak"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload updated README
|
- id: upload-updated-readme
|
||||||
|
name: Upload updated README
|
||||||
|
if: steps.check-readme.outputs.changed == 'true'
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: updated-readme
|
name: updated-readme
|
||||||
@@ -184,29 +196,34 @@ jobs:
|
|||||||
|
|
||||||
commit-readme:
|
commit-readme:
|
||||||
needs: generate-readme
|
needs: generate-readme
|
||||||
|
if: needs.generate-readme.outputs.readme_changed == 'true'
|
||||||
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: Download README
|
- id: download-updated-readme
|
||||||
|
name: Download README
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: updated-readme
|
name: updated-readme
|
||||||
path: .
|
path: .
|
||||||
|
|
||||||
- name: Checkout Repository
|
- id: checkout-code
|
||||||
|
name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.TOKEN }}
|
token: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
- name: Configure Git
|
- id: 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: Commit and Push README
|
- id: commit-and-push
|
||||||
|
name: Commit and Push README
|
||||||
run: |
|
run: |
|
||||||
git config advice.addIgnoredFile false
|
git config advice.addIgnoredFile false
|
||||||
git add README.md
|
git add README.md
|
||||||
|
|||||||
Reference in New Issue
Block a user