Rebase release proposal #2
Workflow file for this run
This file contains 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: Rebase release proposal | |
on: | |
workflow_dispatch: | |
inputs: | |
base-branch: | |
description: 'Branch to rebase onto' | |
required: true | |
type: choice | |
options: | |
- v4.x | |
- v5.x | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Git | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Get PR details | |
id: get_pr | |
run: | | |
pr_number=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number') | |
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Check PR approval | |
id: check_approval | |
run: | | |
approvals=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews" \ | |
| jq '[.[] | select(.state == "APPROVED")] | length') | |
if [ "$approvals" -eq 0 ]; then | |
exit 1 | |
fi | |
- name: Check CI status | |
id: check_ci_status | |
run: | | |
status=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/status" \ | |
| jq -r '.state') | |
if [ "$status" != "success" ]; then | |
exit 1 | |
fi | |
release: | |
needs: check | |
runs-on: ubuntu-latest | |
permissions: write-all | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GH_ACCESS_TOKEN_RELEASE }} | |
- name: Set up Git | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Checkout base branch | |
run: | | |
git checkout ${{ github.event.inputs.base-branch }} | |
- name: Rebase branch | |
run: | | |
git rebase ${{ github.ref_name }} | |
- name: Push rebased branch | |
run: | | |
git push |