Skip to content

Commit 952624d

Browse files
committed
Create a separate branch for the updated redist
1 parent a4410fd commit 952624d

31 files changed

+40777
-12
lines changed

.github/workflows/Update.Unturned.Redist.yaml

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ on:
2121
permissions:
2222
contents: write
2323
packages: write
24+
pull-requests: write
2425

2526
concurrency:
2627
group: unturned-redist-update-${{ github.ref }}
@@ -54,8 +55,6 @@ jobs:
5455
strategy:
5556
matrix:
5657
variant: ${{ fromJson(needs.determine-variants.outputs.variants) }}
57-
# Run sequentially, one variant at a time
58-
max-parallel: 1
5958
fail-fast: false
6059

6160
steps:
@@ -77,11 +76,22 @@ jobs:
7776
server) echo "REDIST_DIR=redist/redist-server" >> $GITHUB_ENV ;;
7877
*) echo "REDIST_DIR=redist/redist-unknown" >> $GITHUB_ENV ;;
7978
esac
79+
80+
# Generate unique branch name
81+
timestamp=$(date +%Y%m%d-%H%M%S)
82+
echo "BRANCH_NAME=redist-update/${{ matrix.variant }}-${timestamp}" >> $GITHUB_ENV
8083
8184
- name: Checkout repository
8285
uses: actions/checkout@v4
8386
with:
8487
ref: master
88+
token: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- name: Create and switch to update branch
91+
run: |
92+
git config --global user.email "[email protected]"
93+
git config --global user.name "sunnamed434"
94+
git checkout -b "$BRANCH_NAME"
8595
8696
- name: Download update tool
8797
uses: robinraju/release-downloader@v1
@@ -140,20 +150,68 @@ jobs:
140150
echo "message=$msg" >> "$GITHUB_OUTPUT"
141151
id: generate_commit_message
142152

143-
- name: Commit changes
144-
if: success()
153+
- name: Check for changes
154+
id: check_changes
145155
run: |
146-
git config --global user.email "[email protected]"
147-
git config --global user.name "sunnamed434"
148-
149156
if git diff --quiet; then
157+
echo "has_changes=false" >> $GITHUB_OUTPUT
150158
echo "No changes detected for ${{ matrix.variant }}"
151159
else
152-
git add -A
153-
git reset README.md # Reset README.md, cause steamcmd override it.
154-
git status
155-
git commit -m "${{ steps.generate_commit_message.outputs.message }}"
156-
git push
160+
echo "has_changes=true" >> $GITHUB_OUTPUT
161+
echo "Changes detected for ${{ matrix.variant }}"
162+
fi
163+
164+
- name: Commit and push changes
165+
if: steps.check_changes.outputs.has_changes == 'true'
166+
run: |
167+
git add -A
168+
git reset README.md # Reset README.md, cause steamcmd override it.
169+
git status
170+
git commit -m "${{ steps.generate_commit_message.outputs.message }}"
171+
git push origin "$BRANCH_NAME"
172+
173+
- name: Create Pull Request
174+
if: steps.check_changes.outputs.has_changes == 'true'
175+
id: create_pr
176+
uses: peter-evans/create-pull-request@v7
177+
with:
178+
token: ${{ secrets.GITHUB_TOKEN }}
179+
branch: ${{ env.BRANCH_NAME }}
180+
base: master
181+
title: "🤖 Auto-update ${{ matrix.variant }} redist files"
182+
body: |
183+
## Automated Redist Update - ${{ matrix.variant }}
184+
185+
This PR contains automatically updated redist files for the **${{ matrix.variant }}** variant.
186+
187+
### Changes
188+
${{ steps.generate_commit_message.outputs.message }}
189+
190+
### Validation
191+
🔄 Validation will run automatically when this PR is created.
192+
193+
---
194+
195+
**Triggered by**: ${{ github.event_name == 'workflow_dispatch' && 'Manual dispatch' || 'Scheduled run' }}
196+
**Variant**: ${{ matrix.variant }}
197+
**Branch**: `${{ env.BRANCH_NAME }}`
198+
199+
> This PR was automatically created by the Unturned Redist update workflow.
200+
> Validation checks will run automatically. Review the changes carefully before merging.
201+
draft: false
202+
labels: |
203+
automated
204+
redist-update
205+
${{ matrix.variant }}
206+
207+
- name: Summary
208+
run: |
209+
echo "## Update Summary for ${{ matrix.variant }}" >> $GITHUB_STEP_SUMMARY
210+
echo "- **Branch**: \`${{ env.BRANCH_NAME }}\`" >> $GITHUB_STEP_SUMMARY
211+
echo "- **Has Changes**: ${{ steps.check_changes.outputs.has_changes }}" >> $GITHUB_STEP_SUMMARY
212+
if [[ "${{ steps.check_changes.outputs.has_changes }}" == "true" ]]; then
213+
echo "- **PR Created**: #${{ steps.create_pr.outputs.pull-request-number }}" >> $GITHUB_STEP_SUMMARY
214+
echo "- **PR URL**: ${{ steps.create_pr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY
157215
fi
158216
159217
workflow-keepalive:
4.12 MB
Binary file not shown.

0 commit comments

Comments
 (0)