Skip to content

Commit 21fbdf6

Browse files
Move to using a script action to create the PR.
Create a test workflow for ... testing.
1 parent a4d2dde commit 21fbdf6

File tree

2 files changed

+59
-8
lines changed

2 files changed

+59
-8
lines changed

.github/workflows/test-commit.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Increment version and update via PR
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
tag:
6+
description: 'Tag'
7+
required: false
8+
default: ''
9+
add:
10+
description: 'Add files'
11+
required: false
12+
jobs:
13+
release:
14+
name: Release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repo
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Bump version file
23+
shell: bash
24+
run: |
25+
awk '{$1=$1+1;print}' version.txt > version.tmp
26+
cp version.tmp version.txt
27+
cp version.tmp version-extra.txt
28+
rm version.tmp
29+
30+
- name: Commit-PR-merge
31+
uses: ./.github/actions/commit-pr-and-merge
32+
with:
33+
message: 'Update the version file'
34+
tag: ${{ inputs.tag }}
35+
add: ${{ inputs.add }}

actions/commit_pr_and_merge/action.yaml

+24-8
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,39 @@ inputs:
1414
runs:
1515
using: "composite"
1616
steps:
17-
- name: Commit and PR
18-
uses: peter-evans/create-pull-request@v5
17+
- name: Commit to new branch
18+
uses: EndBug/add-and-commit@v9
19+
id: create-branch-and-commit
20+
with:
21+
message: '[CI Pipeline] ${{ inputs.message }}'
22+
author_name: Release Workflow
23+
author_email: [email protected]
24+
new_branch: ci-${{ github.sha }}
25+
add: ${{ inputs.add }}
26+
27+
- name: Create PR
28+
uses: actions/github-script@v7
1929
id: create-pr
2030
with:
21-
commit-message: '[CI Pipeline] ${{ inputs.message }}'
22-
title: '[CI Pipeline] ${{ inputs.message }}'
23-
body: '[CI Pipeline] Automated update'
24-
branch-suffix: short-commit-hash
25-
add-paths: ${{ inputs.add }}
31+
script: |
32+
const newPr = (await github.rest.pulls.create({
33+
owner: context.repo.owner,
34+
repo: context.repo.repo,
35+
title: '[CI Pipeline] ${{ inputs.message }}',
36+
head: 'ci-${{ github.sha }}',
37+
base: '${{ github.ref_name }}',
38+
body: '[CI Pipeline] Automated update'
39+
})).data;
40+
core.setOutput('pull-request-url', newPr.html_url);
41+
core.setOutput('pull-request-number', newPr.number);
2642
2743
- name: Merge PR
2844
run: gh pr merge $PR_URL $MERGE_PR_STRATEGY
2945
shell: bash
3046
env:
3147
GITHUB_TOKEN: ${{ github.token }}
3248
PR_URL: ${{ steps.create-pr.outputs.pull-request-url }}
33-
MERGE_PR_STRATEGY: ${{github.ref_protected == true && '--merge' || '--rebase' }}
49+
MERGE_PR_STRATEGY: ${{github.ref_protected == true && '--merge' || '--rebase' }}
3450

3551
- name: Tag commit
3652
uses: actions/github-script@v7

0 commit comments

Comments
 (0)