create-merge-release-into-dev-pr #11
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: create-merge-release-into-dev-pr | |
on: | |
workflow_dispatch: | |
permissions: {} | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
latest_release_branch: ${{ steps.find_latest_release.outputs.branch }} | |
steps: | |
- id: find_latest_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_REPOSITORY: ${{ github.repository }} | |
run: | | |
BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \ | |
https://api.github.com/repos/$GITHUB_REPOSITORY/branches?protected=true | \ | |
jq -r '.[].name' | grep '^release/' | sort --version-sort | tail -1 | |
) | |
if [ "$BRANCH" = "" ]; then | |
echo "Invalid release branch found: $BRANCH" | |
exit 1 | |
fi | |
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT | |
try-merging: | |
permissions: | |
contents: write # for git push | |
runs-on: ubuntu-latest | |
needs: setup | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: test-dev # TODO: DELETE ME | |
- name: Try merging | |
run: | | |
git fetch origin "$RELEASE_BRANCH" | |
git branch "$RELEASE_BRANCH" origin/"$RELEASE_BRANCH" | |
git diff ..."$RELEASE_BRANCH" | |
git merge --no-edit --no-ff "$RELEASE_BRANCH" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RELEASE_BRANCH: ${{ needs.setup.outputs.latest_release_branch }} | |
create-pr: | |
permissions: | |
pull-requests: write # for creating pull request | |
runs-on: ubuntu-latest | |
needs: [setup, try-merging] | |
timeout-minutes: 5 | |
if: false # TODO: DELETE ME | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Create pull request | |
run: > | |
gh pr create | |
--base "$BASE_BRANCH" | |
--head "$RELEASE_BRANCH" | |
--title "Merge $RELEASE_BRANCH into $BASE_BRANCH" | |
--body 'Created by GitHub action' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BASE_BRANCH: dev | |
RELEASE_BRANCH: ${{ needs.setup.outputs.latest_release_branch }} |