Skip to content

Fix runs-on

Fix runs-on #11

name: Merge to stage after approval

Check failure on line 1 in .github/workflows/merge-to-stage.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/merge-to-stage.yml

Invalid workflow file

(Line: 27, Col: 14): Unrecognized named-value: 'BRANCH_NAME'. Located at position 1 within expression: BRANCH_NAME, (Line: 39, Col: 14): Unrecognized named-value: 'BRANCH_NAME'. Located at position 1 within expression: BRANCH_NAME
run-name: "[Merge to stage] ${{ github.event.pull_request.title}}"
on:
pull_request_target:
permissions:
id-token: write
contents: write
actions: write
pull-requests: write
jobs:
merge-to-stage:
name: Merge to stage after approval
environment: merge-to-stage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Check if branch is already merged
id: is-merged
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
run: |
git fetch origin stage
git fetch origin ${{ BRANCH_NAME }}
if git merge-base --is-ancestor origin/${{ BRANCH_NAME }} origin/stage; then
echo "Branch already merged to stage with no diff. Skipping remaining steps."
echo "skip_merge=true" >> $GITHUB_OUTPUT
fi
- name: Merge to stage
id: merge-to-stage
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
if: steps.is-merged.outputs.skip_merge != 'true'
run: |
git --version
git config --global user.name "$(git log -n1 --pretty=format:'%an')"
git config --global user.email "$(git log -n1 --pretty=format:'%ae')"
git checkout stage
git fetch origin ${{ BRANCH_NAME }}
git merge --no-ff --no-edit origin/"${{ BRANCH_NAME }}"
git push
- name: Login GH CLI tool
if: steps.is-merged.outputs.skip_merge != 'true'
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --hostname ${GITHUB_SERVER_URL/https:\/\//} --with-token
- name: Tag pull request
if: steps.is-merged.outputs.skip_merge != 'true'
run: |
gh pr edit ${{ github.event.pull_request.number }} --add-label "in stage"