1111 description : Upstream repo path in owner/repo format
1212 required : true
1313 type : string
14+ upstream-version-regex :
15+ description : Regex that the upstream version should match
16+ required : false
17+ default : ' ^v\d+\.\d+\.\d+$'
18+ type : string
1419 downstream :
1520 description : Downstream repo path in owner/repo format
1621 required : true
2429 description : Sandbox repo path in owner/repo format. Used as a base to create PR against downstream.
2530 required : true
2631 type : string
32+ sandbox-branch-prefix :
33+ description : Prefix fot the PR branch
34+ required : false
35+ default : ' automated-updates'
36+ type : string
2737 restore-upstream :
2838 description : List of files to be reset using upstream content on merge conflict.
2939 required : false
4454 required : false
4555 default : ' '
4656 type : string
57+ pr-labels :
58+ description : Labels to add to the PR
59+ required : false
60+ default : ' '
61+ type : string
62+ pr-title-prefix :
63+ description : Prefix for the PR title
64+ required : false
65+ default : ' '
66+ type : string
4767 secrets :
4868 cloner-app-id :
4969 description : Github ID of cloner app
@@ -67,14 +87,12 @@ jobs:
6787 name : Perform merge operation
6888 steps :
6989 - name : Get latest upstream tag
90+ uses : oprypin/find-latest-tag@v1
7091 id : upstream
71- run : |
72- UPSTREAM_VERSION=$(curl --fail --silent "https://api.github.com/repos/${{ inputs.upstream }}/releases/latest" | jq -r '.tag_name')
73- if [ "$UPSTREAM_VERSION" == "" ]; then
74- echo "upstream-version is invalid" >> "$GITHUB_OUTPUT"
75- exit 1
76- fi
77- echo "release=${UPSTREAM_VERSION}" >> "$GITHUB_OUTPUT"
92+ with :
93+ repository : ${{ inputs.upstream }}
94+ releases-only : true
95+ regex : ${{ inputs.upstream-version-regex }}
7896 - name : Find github org name from repo name
7997 id : org
8098 run : |
@@ -104,13 +122,13 @@ jobs:
104122 id : version
105123 with :
106124 version : ${{ steps.org.outputs.downstream-version }}
107- compare-to : ${{ steps.upstream.outputs.release }}
125+ compare-to : ${{ steps.upstream.outputs.tag }}
108126 lenient : false # fail if either of the versions cannot be parsed
109127 - name : Check openshift fork status
110128 id : fork-sync
111129 run : |
112130 SEMVER_RESULT="${{ steps.version.outputs.comparison-result }}"
113- echo "${{ inputs.downstream }}@${{ steps.org.outputs.downstream-version }} ${SEMVER_RESULT} ${{ inputs.upstream }}@${{ steps.upstream.outputs.release }}"
131+ echo "${{ inputs.downstream }}@${{ steps.org.outputs.downstream-version }} ${SEMVER_RESULT} ${{ inputs.upstream }}@${{ steps.upstream.outputs.tag }}"
114132 if [ "${SEMVER_RESULT}" == "<" ]; then
115133 echo "status=outdated" >> $GITHUB_OUTPUT
116134 echo "::notice::downstream outdated"
@@ -134,10 +152,10 @@ jobs:
134152 git config user.email 'github-actions[bot]@users.noreply.github.com'
135153 git config --global core.editor "/bin/true"
136154 git fetch https://github.com/${{ inputs.upstream }} --tags
137- - name : Merge with upstream ${{ steps.upstream.outputs.release }} tag
155+ - name : Merge with upstream ${{ steps.upstream.outputs.tag }} tag
138156 id : merge
139157 run : |
140- git merge refs/tags/${{ steps.upstream.outputs.release }} --no-edit || echo 'MERGE_CONFLICT=true' >> $GITHUB_OUTPUT
158+ git merge refs/tags/${{ steps.upstream.outputs.tag }} --no-edit || echo 'MERGE_CONFLICT=true' >> $GITHUB_OUTPUT
141159 - name : Resolve conflict using upstream contents
142160 if : ${{ steps.merge.outputs.MERGE_CONFLICT == 'true' && inputs.restore-upstream != ''}}
143161 run : |
@@ -159,9 +177,9 @@ jobs:
159177 run : git merge --continue
160178 - name : Add VERSION file if not present
161179 run : |
162- is_version_file_present_upstream=$(git ls-tree ${{ steps.upstream.outputs.release }} | grep VERSION || true)
180+ is_version_file_present_upstream=$(git ls-tree ${{ steps.upstream.outputs.tag }} | grep VERSION || true)
163181 # All tags use the vX.Y.Z format currently.
164- version_from_tag=$(echo ${{ steps.upstream.outputs.release }} | sed -e "s/^v//")
182+ version_from_tag=$(echo ${{ steps.upstream.outputs.tag }} | sed -e "s/^v//")
165183 # Perform check only if both remotes have the VERSION file.
166184 if [ -n "$is_version_file_present_upstream" ] && [ -f VERSION ]; then
167185 version_from_file=$(cat VERSION)
@@ -224,15 +242,15 @@ jobs:
224242 uses : rhobs/create-pull-request@v3
225243 id : create-pr
226244 with :
227- title : " [bot] Bump ${{ inputs.downstream }} to ${{ steps.upstream.outputs.release }}"
245+ title : " ${{ inputs.pr-title-prefix }} [bot] Bump ${{ inputs.downstream }} to ${{ steps.upstream.outputs.tag }}"
228246 body : |
229247 ## Description
230248 This is an automated version bump from CI.
231249 The logs for this run can be found [in the syncbot repo actions](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
232250 If you wish to perform this manually, execute the following commands from ${{ inputs.downstream }} repo:
233251 ```
234252 git fetch https://github.com/${{ inputs.upstream }} --tags
235- if ! git merge refs/tags/${{ steps.upstream.outputs.release }} --no-edit; then
253+ if ! git merge refs/tags/${{ steps.upstream.outputs.tag }} --no-edit; then
236254 git checkout --theirs ${{ inputs.restore-upstream }}
237255 git checkout --ours ${{ inputs.restore-downstream }}
238256 git add ${{ inputs.restore-upstream }} ${{ inputs.restore-downstream }}
@@ -247,10 +265,11 @@ jobs:
247265 git diff --cached --exit-code || git commit -s -m "[bot] update rh-manifest.txt"
248266 fi
249267 ```
268+ labels : ${{ inputs.pr-labels }}
250269 author : ' github-actions[bot]<github-actions[bot]@users.noreply.github.com>'
251270 committer : ' github-actions[bot]<github-actions[bot]@users.noreply.github.com>'
252271 signoff : true
253- branch : automated-updates -${{ inputs.downstream-branch }}
272+ branch : ${{ inputs.sandbox-branch-prefix }} -${{ inputs.downstream-branch }}
254273 delete-branch : true
255274 token : ${{ steps.pr.outputs.token }}
256275 push-to-fork : ${{ inputs.sandbox }}
0 commit comments