Files
ermnvldmr.com/.github/workflows/services-www-next-checkout-release-branch.yml
T

60 lines
2.0 KiB
YAML

name: services/www - next/checkout-release-branch
on:
workflow_dispatch:
permissions:
contents: read
actions: read
jobs:
workflow-release-branch:
name: Workflow - Create or Update Release Branch
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine Mode and Branch Name
id: plan
run: |
REF="${{ github.ref_name }}"
if [[ "$REF" =~ ^releases/www/v[0-9]+\.[0-9]+$ ]]; then
# Dispatched against an existing release branch: update it.
echo "mode=update" >> "$GITHUB_OUTPUT"
echo "branch_name=$REF" >> "$GITHUB_OUTPUT"
else
# Dispatched against next (or any other ref): create a new release branch.
BRANCH_NAME=$(bash ci/scripts/semantic-release.sh checkout services/www)
echo "mode=create" >> "$GITHUB_OUTPUT"
echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
fi
- name: Create and Push Branch
if: steps.plan.outputs.mode == 'create'
run: |
git checkout -b ${{ steps.plan.outputs.branch_name }}
git push origin ${{ steps.plan.outputs.branch_name }}
- name: Rebase Existing Branch onto next
if: steps.plan.outputs.mode == 'update'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Bring the release branch up to date with its father (next),
# replaying any release-branch-only commits on top of the latest next.
git fetch origin next
git rebase FETCH_HEAD
git push --force-with-lease origin ${{ steps.plan.outputs.branch_name }}
- name: Trigger Release Workflow
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run services-www-releases-required.yml --ref ${{ steps.plan.outputs.branch_name }}