Skip to content

Commit

Permalink
Merge pull request #2380 from the-events-calendar/repo-sync/actions/m…
Browse files Browse the repository at this point in the history
…aster

🔄 synced file(s) with the-events-calendar/actions
  • Loading branch information
rafsuntaskin authored Feb 11, 2025
2 parents d9c60b9 + 93cf779 commit 6f2a564
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/changelogger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
check-changelog:
name: Check changelog
runs-on: ubuntu-latest
if: "!contains(github.event.pull_request.body, '[skip-changelog]')"
steps:
# clone the repository
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
if: "!contains(github.event.pull_request.body, '[skip-lint]')"
steps:
- name: Checkout the repository
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: 'PHPCS'
on: [pull_request]
jobs:
conditional:
if: "!contains(github.event.pull_request.body, '[skip-phpcs]')"
runs-on: ubuntu-latest
outputs:
has_no_php_changes: ${{ steps.skip.outputs.has_no_php_changes }}
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/release-merge-forward.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: "Release: Merge Forward"
on:
workflow_dispatch:
inputs:
forward-branch:
description: 'Name of the branch to merge into (e.g. release/T25.adamwarlock, master)'
default: release/T25.name
required: true

jobs:
create-branch:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.create-branch.outputs.skip }}
steps:
- name: Print input vars to summary
run: |
echo "### Debugging Inputs" >> $GITHUB_STEP_SUMMARY
echo "- forward-branch: \`${{ github.event.inputs.forward-branch }}\`" >> $GITHUB_STEP_SUMMARY
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.forward-branch }}
fetch-depth: 0

- name: Set up Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "github-actions"
- name: Create and push release branch
id: create-branch
run: |
forwardBranch="${{ github.event.inputs.forward-branch }}"
if git ls-remote --exit-code --heads origin "$forwardBranch"; then
echo "skip=0" >> $GITHUB_OUTPUT
git checkout "$forwardBranch"
else
echo "## Pull Request" >> $GITHUB_STEP_SUMMARY
echo "Branch $forwardBranch does not exist; no need to create a PR." >> $GITHUB_STEP_SUMMARY
# Create and push the branch so that subsequent steps can use it.
git checkout "${{ github.ref_name }}"
git checkout -b "$forwardBranch"
git push origin "$forwardBranch"
echo "skip=1" >> $GITHUB_OUTPUT
fi
create-pull-request:
needs: create-branch
runs-on: ubuntu-latest
# Run only if the branch already existed (skip==0)
if: ${{ needs.create-branch.outputs.skip == '0' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "github-actions"
- name: create new branch from forward branch and merge ref branch.
run: |
forwardBranch="${{ github.event.inputs.forward-branch }}"
HEAD_BRANCH="task/merge-forward-${{ github.ref_name }}-to-$forwardBranch"
git checkout "$forwardBranch"
git checkout -b "$HEAD_BRANCH"
git merge --no-ff "${{ github.ref_name }}"
git push origin "$HEAD_BRANCH"
- name: Create Pull Request using GitHub CLI
id: create_pr
env:
# Use GITHUB_TOKEN so that gh automatically authenticates.
GITHUB_TOKEN: ${{ secrets.GHA_BOT_TOKEN_MANAGER }}
run: |
echo "Creating PR using gh CLI..."
# Define the head branch name for the PR.
HEAD_BRANCH="task/merge-forward-${{ github.ref_name }}-to-${{ github.event.inputs.forward-branch }}"
# Create the PR and capture JSON output.
PR_URL=$(gh pr create \
--base "${{ github.event.inputs.forward-branch }}" \
--head "$HEAD_BRANCH" \
--title "[BOT] Merge forward from '${{ github.ref_name }}' to '${{ github.event.inputs.forward-branch }}'" \
--body "This is an automated PR created by ${{ github.actor }}. It was generated by [this GitHub Action](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) \\n [skip-changelog] [skip-lint] [skip-phpcs]" \
--assignee "${{ github.actor }}" \
--label "automation")
echo "pr_url=${PR_URL}" >> $GITHUB_OUTPUT
- name: Check outputs
run: |
echo "## Pull Request" >> $GITHUB_STEP_SUMMARY
echo "* URL - [${{ steps.create_pr.outputs.pr_url }}](${{ steps.create_pr.outputs.pr_url }})" >> $GITHUB_STEP_SUMMARY

0 comments on commit 6f2a564

Please sign in to comment.