sams matches update #292
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Individual Matche Update | |
concurrency: | |
group: "sams to pages" | |
cancel-in-progress: false | |
on: | |
push: | |
paths: | |
- "_sams/xml/matches/**" | |
env: | |
GITHUB_TOKEN: ${{ secrets.BK_GH_PAT }} | |
MATCHES_SOURCE: _sams/xml/matches/ | |
INDIVIDUAL_MATCHES_TARGET: _spielergebnisse/ | |
jobs: | |
Identify-Update: | |
runs-on: ubuntu-latest | |
outputs: | |
files-updated: ${{ steps.files.outputs.added_modified }} # contains each file modified by the commit who triggered this run | |
steps: | |
- name: Identify Modified Files | |
id: files | |
uses: masesgroup/retrieve-changed-files@v2 | |
with: | |
format: "json" | |
####################### | |
### MATCHES PROCESS ### | |
####################### | |
Process-Matches: | |
needs: Identify-Update | |
continue-on-error: true # if one update fails, the flow should continue | |
strategy: | |
matrix: | |
ids: ${{fromJSON(needs.Identify-Update.outputs.files-updated)}} | |
outputs: | |
upload_required: ${{ steps.upload_status.outputs.required }} # controls the artifact download before commit | |
runs-on: ubuntu-latest | |
steps: | |
- name: Filter & Fetch Matches | |
id: filtered_fetch | |
if: contains( matrix.ids, env.MATCHES_SOURCE ) | |
# checks if the file is a match | |
run: | | |
mkdir -p ${{env.MATCHES_SOURCE}} | |
curl -o ${{matrix.ids}} "https://raw.githubusercontent.com/terijaki/vcmuellheim/main/${{matrix.ids}}" -f --retry 3 --retry-delay 30 | |
echo "${{matrix.ids}}" | |
- name: Cleanup SAMS XML # removes strings that break the XLST | |
id: cleanup_xml | |
run: sed -i -e 's!xmlns="http://sams-server.de/api/xml/ns/matches" !!g' ${{matrix.ids}} | |
- name: Get XSLT templates # Download the templates from our repo | |
id: get_xslt_template | |
if: steps.cleanup_xml.conclusion == 'success' | |
run: | | |
curl -o individual_matches.xslt "https://raw.githubusercontent.com/terijaki/vcmuellheim/main/_sams/xslt/individual_matches.xslt" -f --retry 3 --retry-delay 30 | |
### individual matches ### | |
- name: XSLT processing (individual matches) # Download, install and run the XSLT processor (Saxon to use XSLT 2.0 features) | |
id: individual_matches_xslt | |
if: steps.cleanup_xml.conclusion == 'success' | |
run: | | |
git clone https://github.com/sputnick-dev/saxon-lint.git | |
cd saxon-lint* | |
chmod +x saxon-lint.pl | |
./saxon-lint.pl --help | |
cd .. | |
mkdir -p ${{env.INDIVIDUAL_MATCHES_TARGET}} | |
./saxon-lint/saxon-lint.pl --xslt individual_matches.xslt ${{matrix.ids}} | |
find . -path "*${{env.INDIVIDUAL_MATCHES_TARGET}}*" | |
# the saxon output file & location is declared in the xslt file, not by this command! | |
# this is because we cannot use the season ID, as the target file needs to use the unique match ID | |
- name: Upload Artifact (Individual Matches) | |
id: upload_individual_matches | |
if: steps.individual_matches_xslt.conclusion == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: individual_matches | |
path: ${{env.INDIVIDUAL_MATCHES_TARGET}} | |
- name: Upload Status | |
id: upload_status | |
if: steps.upload_individual_matches.conclusion == 'success' | |
run: echo "required=yes" >> $GITHUB_OUTPUT | |
########################## | |
### GIT UPDATE PROCESS ### | |
########################## | |
Git-Update: | |
needs: | |
- Process-Matches | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Source Code | |
uses: actions/checkout@v3 | |
with: | |
token: ${{env.GITHUB_TOKEN}} | |
fetch-depth: 0 | |
- name: Setup Git Config | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
- name: Download Individual Matches | |
id: download_individual_matches | |
if: contains(needs.Process-Matches.outputs.upload_required, 'yes') | |
continue-on-error: true # sometimes there are no individual match updates | |
uses: actions/download-artifact@v3 | |
with: | |
name: individual_matches | |
path: ${{env.INDIVIDUAL_MATCHES_TARGET}} | |
- name: Commit Individual Matching | |
if: steps.download_individual_matches.conclusion == 'success' | |
continue-on-error: true # don't throw an error as there won't always be changes | |
run: | | |
git add "${{env.INDIVIDUAL_MATCHES_TARGET}}" | |
git commit -m "new or updated individual matches" | |
- name: Git Push | |
if: steps.download_individual_matches.conclusion == 'success' | |
continue-on-error: true # don't throw an error as there won't always be changes | |
run: | | |
git pull --rebase | |
git push origin --all --quiet |