-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: move gate-check to consuming repos #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| name: Find Nightly Candidate | ||
|
|
||
| # Reusable workflow to find eligible nightly tag for promotion | ||
| # Used by repos to implement their own gate-check before calling vscode-promote-prerelease.yml | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| min-tag-age-days: | ||
| description: "Minimum nightly age in days before eligible for promotion" | ||
| required: false | ||
| default: "7" | ||
| type: string | ||
| release-tag: | ||
| description: "Specific release tag to use (overrides min-tag-age-days)" | ||
| required: false | ||
| type: string | ||
| outputs: | ||
| commit-sha: | ||
| description: "Commit SHA that the nightly tag points to" | ||
| value: ${{ jobs.find-nightly.outputs.commit-sha }} | ||
| nightly-tag: | ||
| description: "Nightly tag selected for promotion" | ||
| value: ${{ jobs.find-nightly.outputs.nightly-tag }} | ||
|
|
||
| jobs: | ||
| find-nightly: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| commit-sha: ${{ steps.find.outputs.commit-sha }} | ||
| nightly-tag: ${{ steps.find.outputs.nightly-tag }} | ||
| steps: | ||
| # Checks out the calling repository (not salesforcecli/github-workflows) | ||
| # Note: May need explicit token parameter if calling from private repos | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Find eligible nightly | ||
| id: find | ||
| env: | ||
| RELEASE_TAG: ${{ inputs.release-tag || '' }} | ||
| MIN_TAG_AGE_DAYS: ${{ inputs.min-tag-age-days || '7' }} | ||
| run: | | ||
| # If specific release-tag provided, use it directly | ||
| if [ -n "$RELEASE_TAG" ]; then | ||
| echo "Using specific release tag: $RELEASE_TAG" | ||
|
|
||
| if ! git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then | ||
| echo "❌ Release tag $RELEASE_TAG does not exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| COMMIT_SHA=$(git rev-parse "$RELEASE_TAG^{commit}") | ||
| echo "nightly-tag=$RELEASE_TAG" >> $GITHUB_OUTPUT | ||
| echo "commit-sha=$COMMIT_SHA" >> $GITHUB_OUTPUT | ||
| echo "✅ Found release tag: $RELEASE_TAG (commit: $COMMIT_SHA)" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Auto-detect mode: find nightly tags older than MIN_TAG_AGE_DAYS | ||
| echo "Finding nightly tags older than $MIN_TAG_AGE_DAYS days..." | ||
|
|
||
| NIGHTLY_TAGS=$(git tag -l '*-nightly.*' --sort=-creatordate) | ||
|
|
||
| if [ -z "$NIGHTLY_TAGS" ]; then | ||
| echo "❌ No nightly tags found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| CUTOFF_TIMESTAMP=$(date -u -d "$MIN_TAG_AGE_DAYS days ago" +%s 2>/dev/null || date -u -v-${MIN_TAG_AGE_DAYS}d +%s) | ||
|
|
||
| while IFS= read -r tag; do | ||
| [ -z "$tag" ] && continue | ||
|
|
||
| TAG_TIMESTAMP=$(git log -1 --format=%ct "$tag" 2>/dev/null) | ||
| [ -z "$TAG_TIMESTAMP" ] && continue | ||
|
|
||
| if [ "$TAG_TIMESTAMP" -lt "$CUTOFF_TIMESTAMP" ]; then | ||
| VERSION=$(echo "$tag" | grep -oP '\d+\.\d+\.\d+' | head -1) | ||
| PROMO_TAG="marketplace-prerelease-*-v${VERSION}" | ||
|
|
||
| if ! git tag -l "$PROMO_TAG" | grep -q .; then | ||
| SELECTED_TAG="$tag" | ||
| SELECTED_SHA=$(git rev-list -n 1 "$tag") | ||
| echo "nightly-tag=$SELECTED_TAG" >> $GITHUB_OUTPUT | ||
| echo "commit-sha=$SELECTED_SHA" >> $GITHUB_OUTPUT | ||
| echo "✅ Found eligible nightly: $SELECTED_TAG (SHA: $SELECTED_SHA)" | ||
| exit 0 | ||
| fi | ||
| fi | ||
| done <<< "$NIGHTLY_TAGS" | ||
|
|
||
| echo "❌ No eligible nightly found (all nightlies either too new or already promoted)" | ||
| exit 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it need to specify which repo it's checking out? If it's the "calling" repo, does it need to receive a valid token for that (ex: in the case of a private repo) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I double checked and dry run indeed pulled the correct repo (caller). Since the callers today are not private I think it should be fine as it is for now. Will comment for posterity.