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