Skip to content

Commit 6e77ab7

Browse files
committed
Merge branch 'german-ptu' of https://github.com/ROBdk97/StarCitizen-Localization into german-ptu
2 parents 4e57205 + 7d08737 commit 6e77ab7

File tree

3 files changed

+985
-991
lines changed

3 files changed

+985
-991
lines changed

.github/workflows/validate-global-ini.yaml

+45-15
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,73 @@ jobs:
2121
name: Prepare environment
2222
runs-on: ubuntu-latest
2323
outputs:
24-
changed-files: ${{ steps.changed-files.outputs.all_changed_files }}
25-
changed-files-count: ${{ steps.changed-files.outputs.all_changed_files_count }}
24+
changed-files: ${{ steps.find-changed-files.outputs.changed_files }}
25+
changed-files-count: ${{ steps.find-changed-files.outputs.changed_files_count }}
2626

2727
steps:
2828
- name: Checkout current repository
2929
uses: actions/checkout@v3
30-
31-
- name: Get all "global.ini" files that have changed
32-
id: changed-files
33-
uses: tj-actions/changed-files@v39
3430
with:
35-
files: "data/Localization/*/global.ini"
36-
separator: "\" \""
31+
fetch-depth: 0 # Fetch all history for comparing changes
32+
33+
- name: Find changed global.ini files
34+
id: find-changed-files
35+
run: |
36+
echo "${{ github.event_name }} event triggered this workflow"
37+
38+
# Determine the base and head references based on the event type
39+
if [ "${{ github.event_name }}" == "pull_request" ]; then
40+
BASE_REF="${{ github.event.pull_request.base.sha }}"
41+
HEAD_REF="${{ github.event.pull_request.head.sha }}"
42+
elif [ "${{ github.event_name }}" == "push" ]; then
43+
BASE_REF="HEAD^"
44+
HEAD_REF="HEAD"
45+
else
46+
# For workflow_dispatch or any other event, compare with the main branch
47+
git fetch origin main
48+
BASE_REF="origin/main"
49+
HEAD_REF="HEAD"
50+
fi
51+
52+
echo "Comparing $BASE_REF...$HEAD_REF"
53+
54+
# Get changed files with a single git diff command
55+
# Using quotes around the grep pattern to prevent shell expansion of the asterisk
56+
CHANGED_FILES=$(git diff --name-only $BASE_REF $HEAD_REF | grep -E "data/Localization/.*/global\.ini" || echo "")
57+
58+
# Format the files for output with correct separator
59+
if [ ! -z "$CHANGED_FILES" ]; then
60+
# Properly format the changed files for the output with quotes and spaces
61+
FORMATTED_FILES=$(echo "$CHANGED_FILES" | sed 's/.*/"&"/' | tr '\n' ' ')
62+
echo "Changed files: $FORMATTED_FILES"
63+
echo "changed_files=$FORMATTED_FILES" >> $GITHUB_OUTPUT
64+
echo "changed_files_count=$(echo "$CHANGED_FILES" | wc -l)" >> $GITHUB_OUTPUT
65+
else
66+
echo "No global.ini files changed"
67+
echo "changed_files=''" >> $GITHUB_OUTPUT
68+
echo "changed_files_count=0" >> $GITHUB_OUTPUT
69+
fi
3770
3871
- name: List all changed files
39-
run: echo "Changed files ${{ steps.changed-files.outputs.all_changed_files }}"
72+
run: echo "Changed files ${{ steps.find-changed-files.outputs.changed-files }}"
4073

4174
validate-encoding:
4275
name: Validate global.ini Encoding
4376
runs-on: ubuntu-latest
4477
needs: prepare
45-
78+
if: needs.prepare.outputs.changed-files-count > 0
4679
steps:
4780
- name: Checkout current repository
48-
if: needs.prepare.outputs.changed-files-count > 0
4981
uses: actions/checkout@v3
5082

5183
- name: Validate encoding
52-
if: needs.prepare.outputs.changed-files-count > 0
53-
run: bash tools/validate-encoding.bash "${{ needs.prepare.outputs.changed-files }}"
84+
run: bash tools/validate-encoding.bash ${{ needs.prepare.outputs.changed-files }}
5485

5586
validate-entries:
5687
name: Validate global.ini Entries
5788
runs-on: ubuntu-latest
5889
needs: prepare
5990
if: needs.prepare.outputs.changed-files-count > 0
60-
6191
steps:
6292
- name: Checkout current repository
6393
uses: actions/checkout@v3
@@ -77,4 +107,4 @@ jobs:
77107
run: npm run build
78108

79109
- name: Validate key/value pairs
80-
run: node ./tools/ini-utils/dist/src/index.js validate --ci "$GITHUB_WORKSPACE/data/Localization/english/global.ini" "${{ needs.prepare.outputs.changed-files }}"
110+
run: node ./tools/ini-utils/dist/src/index.js validate --ci "$GITHUB_WORKSPACE/data/Localization/english/global.ini" ${{ needs.prepare.outputs.changed-files }}

0 commit comments

Comments
 (0)