Skip to content

Commit

Permalink
Trigger PR from CURL using token
Browse files Browse the repository at this point in the history
  • Loading branch information
LogFlames committed Dec 20, 2024
1 parent 7711f3b commit 95cc6da
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions .github/workflows/jreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,34 @@ jobs:
git commit -am "🔖 Setting SNAPSHOT version ${{ env.NEXT_RELEASE_VERSION }}"
git push --set-upstream origin ${{ env.BRANCH_NAME }}
- name: Merge Fast Forward
env:
GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }}
run: |
git checkout main
git merge --ff-only ${{ env.BRANCH_NAME }}
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
git push origin main
- name: Attempt Push with Retry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RETRY_MAX_TIME: 600
RETRY_INTERVAL: 10
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.JRELEASER_GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/pulls \
-d '{"title":"Release ${{ env.BRANCH_NAME }} ff-merge","body":"PR to trigger tests required for branch protection rules","head":"${{ env.BRANCH_NAME }}","base":"main"}'
START_TIME=$(date +%s)
while true; do
git push origin main && break
ELAPSED_TIME=$(( $(date +%s) - START_TIME ))
if [ "$ELAPSED_TIME" -ge $RETRY_MAX_TIME ]; then
echo "Push failed after $RETRY_MAX_TIME seconds. Exiting..."
exit 1
fi
echo "Push failed. Retrying in $RETRY_INTERVAL seconds..."
sleep $RETRY_INTERVAL
done
# Log failure:
- name: JReleaser release output
if: always()
Expand Down

0 comments on commit 95cc6da

Please sign in to comment.