Skip to content

Commit dfdbae6

Browse files
committed
VMI-1550 Force-push branch from master on each run
1 parent d0155d6 commit dfdbae6

1 file changed

Lines changed: 28 additions & 10 deletions

File tree

.github/workflows/update-adapter.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828

2929
steps:
3030
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
3133

3234
- name: Configure git
3335
run: |
@@ -43,21 +45,37 @@ jobs:
4345
echo " → $pkg"
4446
python3 -c "import json,os; d=json.load(open('$pkg')); [p.update({'state':{'revision':os.environ['SPM_COMMIT_SHA'],'version':os.environ['HYBID_VERSION']}}) for p in d['pins'] if p['identity']=='hybid-ios-spm-sdk']; [p.update({'state':{'branch':'master','revision':os.environ['ADAPTER_SHA']}}) for p in d['pins'] if p['identity']=='applovinmediationvervecustomnetworkadapter']; open('$pkg','w').write(json.dumps(d,indent=2))"
4547
done
46-
echo "─── Diff preview ────────────────────────────────────────────"
47-
git diff
48-
echo "─────────────────────────────────────────────────────────────"
4948
5049
- name: Commit, push branch and open PR
5150
env:
5251
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5352
run: |
5453
BRANCH="update-applovin-adapter-${ADAPTER_VERSION}"
55-
git checkout -b "$BRANCH"
54+
55+
# Always reset branch to master — this branch belongs to automation
56+
git checkout -B "$BRANCH"
57+
5658
git add -A
59+
60+
# Skip if nothing changed vs master
61+
if git diff --cached --quiet; then
62+
echo "No changes to commit — already up to date for v$ADAPTER_VERSION"
63+
exit 0
64+
fi
65+
5766
git commit -m "Pod AppLovinMediationVerveCustomNetworkAdapter v: $ADAPTER_VERSION is added"
58-
git push origin "$BRANCH"
59-
gh pr create \
60-
--title "Pod AppLovinMediationVerveCustomNetworkAdapter v: $ADAPTER_VERSION is added" \
61-
--body "Automated update: bumps AppLovin adapter to v$ADAPTER_VERSION (SPM)." \
62-
--base master \
63-
--head "$BRANCH"
67+
68+
# Force push — overwrites any manual changes on this branch
69+
git push --force-with-lease origin "$BRANCH" 2>/dev/null \
70+
|| git push --force origin "$BRANCH"
71+
72+
# Open PR only if one doesn't already exist
73+
if gh pr view "$BRANCH" --repo "$GITHUB_REPOSITORY" &>/dev/null; then
74+
echo "PR already exists for $BRANCH — skipping"
75+
else
76+
gh pr create \
77+
--title "Pod AppLovinMediationVerveCustomNetworkAdapter v: $ADAPTER_VERSION is added" \
78+
--body "Automated update: bumps AppLovin adapter to v$ADAPTER_VERSION (SPM)." \
79+
--base master \
80+
--head "$BRANCH"
81+
fi

0 commit comments

Comments
 (0)