Skip to content

Remove unnecessary pins #20

Remove unnecessary pins

Remove unnecessary pins #20

Workflow file for this run

name: Merge PR into Dynamic Branch on Label
on:
pull_request_target:
types: [labeled, synchronize]
branches:
- master
permissions:
contents: write
pull-requests: read
jobs:
merge-to-dynamic-branch:
if: github.event.label.name != 'do-not-merge' #Excludes those labeled with do-not-merge
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Check PR Labels and Merge for New Commit Events
if: github.event.action == 'synchronize'
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LABELS_JSON=$(gh pr view "$PR_NUMBER" --json labels)
LABELS=$(echo "$LABELS_JSON" | jq -r '.labels[].name')
for LABEL_BRANCH in $LABELS; do
# Check if the branch exists
if git show-ref --verify --quiet "refs/heads/$LABEL_BRANCH"; then
echo "Branch $LABEL_BRANCH already exists."
else
echo "Branch $LABEL_BRANCH does not exist, creating it."
git branch "$LABEL_BRANCH" origin/master
fi
git checkout "$LABEL_BRANCH"
# Merge PR changes into dynamic branch
git merge "$PR_SHA" --no-ff --no-commit
git commit -m "Merged PR #${PR_NUMBER} due to new commits on labeled PR"
git push origin "$LABEL_BRANCH"
done
- name: Merge for Labeled Event
if: github.event.action == 'labeled'
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_SHA: ${{ github.event.pull_request.head.sha }}
LABEL_BRANCH: ${{ github.event.label.name }}
run: |
# Check if the branch exists
if git show-ref --verify --quiet "refs/heads/$LABEL_BRANCH"; then
echo "Branch $LABEL_BRANCH already exists."
else
echo "Branch $LABEL_BRANCH does not exist, creating it."
git branch "$LABEL_BRANCH" origin/master
fi
git checkout "$LABEL_BRANCH"
# Merge PR changes into dynamic branch
git merge "$PR_SHA" --no-ff --no-commit
git commit -m "Merged PR #${PR_NUMBER} due to label '${LABEL_BRANCH}'"
git push origin "$LABEL_BRANCH"