2828 name : Recreate LTS Release
2929 runs-on : ubuntu-latest
3030 outputs :
31- lts_tag : ${{ steps.vars .outputs.LTS_TAG }}
32- release_tag : ${{ steps.set_release_tag .outputs.release_tag }}
31+ lts_tag : ${{ steps.set_outputs .outputs.lts_tag }}
32+ release_tag : ${{ steps.set_outputs .outputs.release_tag }}
3333
3434 steps :
3535 - name : Checkout repository
8686
8787 - name : Check if Release is LTS
8888 id : check_lts
89- if : github.event_name == 'workflow_run' && steps.get_release.outputs.skip != 'true'
89+ if : steps.get_release.outputs.skip != 'true' || github.event_name == 'workflow_dispatch '
9090 run : |
91- RELEASE_TAG="${{ steps.get_release.outputs.release_tag }}"
91+ # Get release tag based on trigger type
92+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
93+ RELEASE_TAG="${{ inputs.release_tag }}"
94+ else
95+ RELEASE_TAG="${{ steps.get_release.outputs.release_tag }}"
96+ fi
9297
9398 # Read LTS versions from config file (remove comments and empty lines)
9499 LTS_VERSIONS=$(grep -v '^#' .github/lts-versions.txt | grep -v '^$' | tr '\n' '|' | sed 's/|$//')
@@ -132,14 +137,36 @@ jobs:
132137 echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
133138 echo "Validated release tag: $RELEASE_TAG"
134139
140+ - name : Determine if workflow should proceed
141+ id : should_proceed
142+ run : |
143+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
144+ # workflow_dispatch: check LTS validation result
145+ if [ "${{ steps.check_lts.outputs.skip }}" == "true" ]; then
146+ echo "proceed=false" >> "$GITHUB_OUTPUT"
147+ echo "Skipping: Release is not configured as LTS"
148+ else
149+ echo "proceed=true" >> "$GITHUB_OUTPUT"
150+ echo "Proceeding with workflow_dispatch"
151+ fi
152+ elif [ "${{ steps.get_release.outputs.skip }}" == "true" ] || [ "${{ steps.check_lts.outputs.skip }}" == "true" ]; then
153+ # workflow_run: skip if either check failed
154+ echo "proceed=false" >> "$GITHUB_OUTPUT"
155+ echo "Skipping: release check or LTS check failed"
156+ else
157+ # workflow_run: proceed if both checks passed
158+ echo "proceed=true" >> "$GITHUB_OUTPUT"
159+ echo "Proceeding with workflow_run"
160+ fi
161+
135162 - name : Set up Git identity
136- if : github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && steps.get_release .outputs.skip != 'true' && steps.check_lts.outputs.skip ! = 'true')
163+ if : steps.should_proceed .outputs.proceed = = 'true'
137164 run : |
138165 git config user.name "github-actions"
139166 git config user.email "github-actions@github.com"
140167
141168 - name : Determine LTS tag and update
142- if : github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && steps.get_release .outputs.skip != 'true' && steps.check_lts.outputs.skip ! = 'true')
169+ if : steps.should_proceed .outputs.proceed = = 'true'
143170 id : vars
144171 env :
145172 RELEASE_TAG : ${{ steps.set_release_tag.outputs.release_tag }}
@@ -152,8 +179,12 @@ jobs:
152179 LTS_TAG="${SHORT_TAG}-lts"
153180 echo "LTS_TAG=$LTS_TAG" >> "$GITHUB_OUTPUT"
154181
155- # Force update the tag to the current commit
156- git tag -f "$LTS_TAG" $GITHUB_SHA
182+ # Get the commit SHA that the release tag points to
183+ RELEASE_SHA=$(git rev-parse "$RELEASE_TAG^{}")
184+ echo "Release tag $RELEASE_TAG points to commit: $RELEASE_SHA"
185+
186+ # Force update the LTS tag to point to the same commit as the release
187+ git tag -f "$LTS_TAG" "$RELEASE_SHA"
157188 git push origin -f "$LTS_TAG"
158189
159190 # Get release body from the original release
@@ -165,7 +196,7 @@ jobs:
165196 echo "EOF" >> "$GITHUB_ENV"
166197
167198 - name : Delete existing LTS release (if any)
168- if : github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && steps.get_release .outputs.skip != 'true' && steps.check_lts.outputs.skip ! = 'true')
199+ if : steps.should_proceed .outputs.proceed = = 'true'
169200 continue-on-error : true
170201 env :
171202 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -175,14 +206,22 @@ jobs:
175206 gh release delete "$LTS_TAG" -y
176207
177208 - name : Create fresh LTS release
178- if : github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && steps.get_release .outputs.skip != 'true' && steps.check_lts.outputs.skip ! = 'true')
209+ if : steps.should_proceed .outputs.proceed = = 'true'
179210 env :
180211 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
181212 LTS_TAG : ${{ steps.vars.outputs.LTS_TAG }}
182213 RELEASE_BODY : ${{ env.RELEASE_BODY }}
183214 run : |
184215 echo "Creating new GitHub release for $LTS_TAG"
185216 gh release create "$LTS_TAG" --title "$LTS_TAG" --notes "$RELEASE_BODY"
217+
218+ - name : Set Job Outputs
219+ id : set_outputs
220+ if : steps.should_proceed.outputs.proceed == 'true'
221+ run : |
222+ echo "lts_tag=${{ steps.vars.outputs.LTS_TAG }}" >> "$GITHUB_OUTPUT"
223+ echo "release_tag=${{ steps.set_release_tag.outputs.release_tag }}" >> "$GITHUB_OUTPUT"
224+ echo "Set job outputs for downstream job"
186225
187226 tag-lts-images :
188227 name : Tag Existing Images with LTS
0 commit comments