diff --git a/.github/workflows/backport-label-audit.yml b/.github/workflows/backport-label-audit.yml new file mode 100644 index 0000000000..9bab1cc679 --- /dev/null +++ b/.github/workflows/backport-label-audit.yml @@ -0,0 +1,54 @@ +name: Backport Label Audit + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version to audit (e.g., 1.13). Leave empty to audit all versions.' + required: false + type: string + dry_run: + description: 'Dry run (only report, do not modify)' + required: true + type: choice + options: + - 'true' + - 'false' + default: 'true' + +jobs: + audit-backport-labels: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Checkout Backporter + uses: actions/checkout@v4 + with: + repository: KristofferC/Backporter + ref: master + path: backporter + + - name: Setup Julia + uses: julia-actions/setup-julia@v2 + with: + version: '1' + + - name: Install dependencies + run: | + cd backporter + julia --project -e 'using Pkg; Pkg.instantiate()' + + - name: Run backport label audit + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd backporter + ARGS="--audit -r ${{ github.repository }}" + if [ -n "${{ inputs.version }}" ]; then + ARGS="$ARGS -v ${{ inputs.version }}" + fi + if [ "${{ inputs.dry_run }}" = "false" ]; then + ARGS="$ARGS --apply" + fi + julia --project backporter.jl $ARGS diff --git a/.github/workflows/backport-label-cleanup.yml b/.github/workflows/backport-label-cleanup.yml new file mode 100644 index 0000000000..8cfad3db0a --- /dev/null +++ b/.github/workflows/backport-label-cleanup.yml @@ -0,0 +1,56 @@ +name: Backport Label Cleanup + +on: + pull_request: + types: [closed] + branches: + - 'release-*' + +jobs: + remove-backport-labels: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Extract version from branch + id: extract + run: | + BRANCH="${{ github.event.pull_request.base.ref }}" + if [[ "$BRANCH" =~ ^release-([0-9]+\.[0-9]+)$ ]]; then + echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT" + else + echo "Branch $BRANCH does not match release-X.Y pattern" + exit 0 + fi + + - name: Checkout Backporter + if: steps.extract.outputs.version != '' + uses: actions/checkout@v4 + with: + repository: KristofferC/Backporter + ref: master + path: backporter + + - name: Setup Julia + if: steps.extract.outputs.version != '' + uses: julia-actions/setup-julia@v2 + with: + version: '1' + + - name: Install dependencies + if: steps.extract.outputs.version != '' + run: | + cd backporter + julia --project -e 'using Pkg; Pkg.instantiate()' + + - name: Run backport label cleanup + if: steps.extract.outputs.version != '' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd backporter + julia --project backporter.jl --audit \ + -v ${{ steps.extract.outputs.version }} \ + -r ${{ github.repository }} \ + --cleanup-pr ${{ github.event.pull_request.number }}