|
25 | 25 | # still available in the step's summary.) |
26 | 26 | comment: on-error |
27 | 27 | GITHUB_TOKEN: ${{ secrets.ASSOCIATION_RELEASE_TOKEN }} ## This allows to trigger push action from within this workflow. Read more - https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow |
28 | | - |
29 | | - fast-forward-next-rebase: |
30 | | - # Only run if the comment contains the /force-next-ff command. |
31 | | - if: ${{ contains(github.event.comment.body, '/force-next-ff') |
32 | | - && github.event.issue.pull_request}} |
33 | | - runs-on: ubuntu-latest |
34 | | - |
35 | | - permissions: |
36 | | - contents: write |
37 | | - pull-requests: write |
38 | | - issues: write |
39 | | - |
40 | | - steps: |
41 | | - - name: Fast forwarding |
42 | | - uses: sequoia-pgp/fast-forward@v1 |
43 | | - id: fast_forward |
44 | | - with: |
45 | | - merge: true |
46 | | - # To reduce the workflow's verbosity, use 'on-error' |
47 | | - # to only post a comment when an error occurs, or 'never' to |
48 | | - # never post a comment. (In all cases the information is |
49 | | - # still available in the step's summary.) |
50 | | - comment: on-error |
51 | | - GITHUB_TOKEN: ${{ secrets.ASSOCIATION_RELEASE_TOKEN }} ## This allows to trigger push action from within this workflow. Read more - https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow |
52 | | - continue-on-error: true |
53 | | - |
54 | | - - name: Check Fast Forward Result |
55 | | - if: steps.fast_forward.outcome == 'failure' |
56 | | - env: |
57 | | - GH_TOKEN: ${{ secrets.ASSOCIATION_RELEASE_TOKEN }} ## This is needed for gh to work |
58 | | - run: | |
59 | | - # Extract the PR number |
60 | | - PR_URL="${{ github.event.issue.pull_request.url }}" |
61 | | - PR_NUMBER="${PR_URL##*/}" |
62 | | -
|
63 | | - # Get the target branch |
64 | | - TARGET_BRANCH=$(gh pr view $PR_NUMBER --json baseRefName -q '.baseRefName') |
65 | | - echo "Target branch: $TARGET_BRANCH" |
66 | | -
|
67 | | - # Check if the target branch is 'next' |
68 | | - if [ "$TARGET_BRANCH" != "next" ]; then |
69 | | - echo "This PR does not target the 'next' branch. Exiting." |
70 | | - exit 1 |
71 | | - fi |
72 | | -
|
73 | | - # Get the commit SHA |
74 | | - PR_SHA=$(gh pr view $PR_NUMBER --json headRefOid -q '.headRefOid') |
75 | | - echo "PR SHA: $PR_SHA" |
76 | | -
|
77 | | - # Fetch the PR head commit to ensure it is available locally |
78 | | - git fetch origin "pull/${{ github.event.issue.number }}/head" |
79 | | -
|
80 | | - git checkout --detach |
81 | | - # Force update the 'next' branch |
82 | | - git branch -f next $PR_SHA |
83 | | -
|
84 | | - ## push the changes to the next branch |
85 | | - git push -f "https://x-access-token:${{ secrets.ASSOCIATION_RELEASE_TOKEN }}@github.com/${{ github.repository }}.git" next |
0 commit comments