Skip to content

Commit b169deb

Browse files
colorzzrGitHub Actions
and
GitHub Actions
authored
Patch20250327: change workflow to push back to feature branch during PR (#228)
* use github actions as commit user * fixup cli version * change workflow to push back to feature branch during PR * test * test on behavior * test on behavior * Updated docs/compatible_version.ndjson with PR #227 * test on behavior * Updated docs/compatible_version.ndjson with PR #227 * test on behavior * force to update version * Updated docs/compatible_version.ndjson with PR #228 * add step to check if we already update the PR * Updated docs/compatible_version.ndjson with PR #228 * skip the update --------- Co-authored-by: GitHub Actions <[email protected]>
1 parent 7a30eaf commit b169deb

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

Diff for: .github/workflows/update_compatible_version.yml

+33-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
11
name: Update Compatible Versions
22

33
on:
4-
workflow_run:
5-
workflows: [ "Build and Publish" ]
4+
pull_request:
5+
types: [opened, synchronize, reopened] # dont trigger on closed
66
branches:
7+
- main
78
- develop
8-
types:
9-
- completed
10-
11-
pull_request:
12-
types:
13-
- closed # Ensures it runs only on PR closure (merge)
149

1510
jobs:
1611
update-compatible-versions:
17-
if: github.event.pull_request.merged == true # Runs only if PR is merged
1812
runs-on: ubuntu-latest
1913

2014
steps:
2115
- name: Checkout repository
2216
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.head_ref }}
19+
20+
- name: Check if CLI version was already updated
21+
id: check_version
22+
run: |
23+
# Extract current version from pyproject.toml
24+
CURRENT_VERSION=$(grep '^version =' pyproject.toml | sed -E 's/version = "(.*)"/\1/')
25+
echo "Current version: $CURRENT_VERSION"
26+
27+
# Read the last entry from NDJSON file (if it exists)
28+
LAST_VERSION=$(tail -n 1 docs/compatible_version.ndjson 2>/dev/null | jq -r '."Cli Version"')
29+
30+
echo "Last updated version: $LAST_VERSION"
31+
echo "current=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
32+
echo "last=$LAST_VERSION" >> "$GITHUB_OUTPUT"
33+
34+
- name: Exit if already updated
35+
if: ${{ steps.check_version.outputs.current == steps.check_version.outputs.last }}
36+
run: |
37+
echo "This version was already recorded. Skipping update."
2338
2439
- name: Extract Versions from PR
40+
if: ${{ steps.check_version.outputs.current != steps.check_version.outputs.last }}
2541
id: extract_versions
2642
run: |
2743
PR_BODY="${{ github.event.pull_request.body }}"
@@ -50,6 +66,7 @@ jobs:
5066
echo "$NEW_ENTRY" >> docs/compatible_version.ndjson
5167
5268
- name: Embed Compatible Versions into README
69+
if: ${{ steps.check_version.outputs.current != steps.check_version.outputs.last }}
5370
run: |
5471
# Define markers
5572
START_MARKER="<!-- COMPATIBLE_VERSIONS_START -->"
@@ -77,10 +94,15 @@ jobs:
7794
mv README_UPDATED.md README.md
7895
7996
- name: Commit and Push Changes
97+
if: ${{ steps.check_version.outputs.current != steps.check_version.outputs.last }}
8098
run: |
8199
git config user.name "GitHub Actions"
82100
git config user.email "[email protected]"
101+
git pull origin ${{ github.head_ref }}
83102
git add docs/compatible_version.ndjson README.md
84103
git commit -m "Updated docs/compatible_version.ndjson with PR #${{ github.event.pull_request.number }}"
85-
git push
86-
continue-on-error: true # Avoid breaking workflow if no changes detected
104+
105+
- name: Push change to feature branch
106+
if: ${{ steps.check_version.outputs.current != steps.check_version.outputs.last }}
107+
run: |
108+
git push origin HEAD:${{ github.head_ref }} -f

Diff for: README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ Command line tool that allows the user to execute data operations on the platfor
4444
4545
## Compatible versions
4646
<!-- COMPATIBLE_VERSIONS_START -->
47-
47+
| Cli Version | Pilot Release Version | Compatible Version |
48+
|------------|----------------------|---------------------|
49+
| 3.15.0 | 2.14.2 | 2.14.2 |
50+
| 3.15.1 | 2.14.2 | 2.14.2 |
51+
| 3.15.2 | 2.15 | 2.15 |
52+
| 3.16.0 | 2.15 | 2.15 |
53+
| 3.17.0 | 2.15 | 2.15 |
54+
| 3.17.1 | 2.15 | 2.15 |
55+
| 3.17.1 | 2.15 | 2.15 |
4856
<!-- COMPATIBLE_VERSIONS_END -->
4957
5058
## Build Instructions

Diff for: docs/compatible_version.ndjson

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
{"Cli Version": "3.15.2", "Pilot Release Version": "2.15", "Compatible Version": "2.15"}
44
{"Cli Version": "3.16.0", "Pilot Release Version": "2.15", "Compatible Version": "2.15"}
55
{"Cli Version": "3.17.0", "Pilot Release Version": "2.15", "Compatible Version": "2.15"}
6+
{"Cli Version": "3.17.1", "Pilot Release Version": "2.15", "Compatible Version": "2.15"}

0 commit comments

Comments
 (0)