Repository navigation
Update Offsets #12
This file contains hidden or 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: Update Offsets | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 2 * * 6' | |
| concurrency: | |
| group: ss_offsets-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| update-offsets: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v7 | |
| - name: Fetch Upstream | |
| run: | | |
| git ls-remote https://github.com/acidlabsgg/gtav-legacy-scripts HEAD | cut -f1 > legacy_upstream.txt | |
| git ls-remote https://github.com/acidlabsgg/gtav-enhanced-scripts HEAD | cut -f1 > enhanced_upstream.txt | |
| - name: Read Saved Commit Hashes | |
| id: saved_commits | |
| run: | | |
| if [ -f dev/scripts/offsets/legacy.last_commit_hash ]; then | |
| cat dev/scripts/offsets/legacy.last_commit_hash > last_commit_legacy | |
| else | |
| echo "none" > last_commit_legacy | |
| fi | |
| if [ -f dev/scripts/offsets/enhanced.last_commit_hash ]; then | |
| cat dev/scripts/offsets/enhanced.last_commit_hash > last_commit_enhanced | |
| else | |
| echo "none" > last_commit_enhanced | |
| fi | |
| - name: Compare Commits | |
| id: compare_commits | |
| run: | | |
| LEGACY_UPSTREAM=$(cat legacy_upstream.txt) | |
| ENHANCED_UPSTREAM=$(cat enhanced_upstream.txt) | |
| LEGACY_LAST=$(cat last_commit_legacy) | |
| ENHANCED_LAST=$(cat last_commit_enhanced) | |
| echo "Legacy Upstream: $LEGACY_UPSTREAM" | |
| echo "Legacy Last Run: $LEGACY_LAST" | |
| echo "Enhanced Upstream: $ENHANCED_UPSTREAM" | |
| echo "Enhanced Last Run: $ENHANCED_LAST" | |
| if [ "$LEGACY_UPSTREAM" = "$LEGACY_LAST" ] && [ "$ENHANCED_UPSTREAM" = "$ENHANCED_LAST" ] && [ "${{ github.event_name }}" != "workflow_dispatch" ]; then | |
| echo "run=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "run=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Python | |
| if: steps.compare_commits.outputs.run == 'true' | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12.x" | |
| - name: Run Offset Updater | |
| if: steps.compare_commits.outputs.run == 'true' | |
| run: | | |
| python ./dev/scripts/offsets/update_offsets.py | |
| - name: Save New Commit Hashes | |
| if: steps.compare_commits.outputs.run == 'true' | |
| run: | | |
| cp legacy_upstream.txt ./dev/scripts/offsets/legacy.last_commit_hash | |
| cp enhanced_upstream.txt ./dev/scripts/offsets/enhanced.last_commit_hash | |
| - name: Commit Changes | |
| if: steps.compare_commits.outputs.run == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add dev/scripts/offsets/legacy.last_commit_hash | |
| git add dev/scripts/offsets/enhanced.last_commit_hash | |
| git add SSV2/includes/data/globals_locals.lua | |
| git diff --cached --quiet || git commit -m "chore(offsets): update script globals & locals" | |
| git push |