-
Notifications
You must be signed in to change notification settings - Fork 312
Add browser destination artifact publish workflow #3787
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
Open
varadarajan-tw
wants to merge
14
commits into
main
Choose a base branch
from
build-browser-destinations-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+117
−0
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1945529
Add on-demand workflow to build and upload browser destination bundles
varadarajan-tw 2a3bdf2
Fix security and correctness issues in browser destinations workflow
varadarajan-tw 723aebe
Remove job-level environment gate — deployment approval belongs in th…
varadarajan-tw 752f67f
chore: address Copilot review comments on browser build workflow
itsarijitray 4091af9
Apply suggestions from code review
itsarijitray 7c45741
fix: correct indentation of setup-node uses key in browser build work…
itsarijitray 7448278
chore: align browser build workflow runner and action pins with repo …
itsarijitray 0dd8f15
chore: build browser artifacts during publish
varadarajan-tw e035973
test: run browser artifact build on PR branch
varadarajan-tw 9bd277d
chore: move validated browser build to publish
varadarajan-tw 9d1f72d
chore: gate browser artifact builds on changes
varadarajan-tw a29e4a4
fix: harden browser artifact change detection
varadarajan-tw 88aa2ef
chore: split browser artifact publishing workflow
varadarajan-tw dbeb7da
fix: harden browser artifact lookup
varadarajan-tw 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,117 @@ | ||
| # Short-term workflow for producing browser destination artifacts independently | ||
| # from npm package publishing. Both workflows start concurrently on Publish pushes. | ||
| name: Publish Browser Destination Workflow | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - staging | ||
|
|
||
| jobs: | ||
| detect-browser-destination-changes: | ||
| if: startsWith(github.event.head_commit.message, 'Publish') == true | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| outputs: | ||
| changed: ${{ steps.changes.outputs.changed }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| persist-credentials: false | ||
| ref: ${{ github.sha }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Detect Browser Bundle Changes | ||
| id: changes | ||
| env: | ||
| ARTIFACT_ENVIRONMENT: ${{ github.ref_name == 'staging' && 'stage' || 'production' }} | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| previous_publish='' | ||
| while IFS=$'\t' read -r commit subject; do | ||
| if [[ "$subject" == Publish* ]]; then | ||
| previous_publish="$commit" | ||
| break | ||
| fi | ||
| done < <(git log --first-parent --format='%H%x09%s' HEAD^) | ||
|
|
||
| if [ -z "$previous_publish" ]; then | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| elif ! git diff --quiet "$previous_publish" HEAD -- \ | ||
| packages/browser-destinations/ \ | ||
| packages/browser-destination-runtime/ \ | ||
| packages/core/ \ | ||
| packages/actions-shared/ \ | ||
| packages/ajv-human-errors/ \ | ||
| packages/destination-subscriptions/; then | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| artifact_name="browser-destinations-${ARTIFACT_ENVIRONMENT}-${previous_publish}" | ||
|
|
||
| if artifacts=$(gh api --method GET \ | ||
| "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/artifacts" \ | ||
| -f name="$artifact_name" \ | ||
| -f per_page=100) && \ | ||
| artifact_count=$(jq --arg name "$artifact_name" \ | ||
| '[.artifacts[] | select(.name == $name and .expired == false)] | length' \ | ||
| <<< "$artifacts") && \ | ||
| [ "$artifact_count" -gt 0 ]; then | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| fi | ||
|
|
||
| build-browser-destinations: | ||
| needs: detect-browser-destination-changes | ||
| env: | ||
| HUSKY: 0 | ||
| NX_DISABLE_DB: true | ||
| if: needs.detect-browser-destination-changes.outputs.changed == 'true' | ||
| runs-on: ubuntu-latest-large | ||
|
|
||
| timeout-minutes: 20 | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
Comment on lines
+77
to
+78
|
||
| with: | ||
| persist-credentials: false | ||
| ref: ${{ github.sha }} | ||
|
|
||
| - name: Verify Checkout Commit | ||
| run: test "$(git rev-parse HEAD)" = "$GITHUB_SHA" | ||
|
|
||
| - name: Use Node.js 22.x | ||
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | ||
| with: | ||
| node-version: 22.x | ||
| cache: yarn | ||
|
|
||
| - name: Install Dependencies | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Build Destinations Manifest | ||
| run: yarn nx build @segment/destinations-manifest | ||
|
|
||
| - name: Build Production Browser Bundles | ||
| if: github.ref_name == 'main' | ||
| working-directory: packages/browser-destinations | ||
| run: yarn build-web | ||
|
|
||
| - name: Build Stage Browser Bundles | ||
| if: github.ref_name == 'staging' | ||
| working-directory: packages/browser-destinations | ||
| run: yarn build-web-stage | ||
|
|
||
| - name: Upload Browser Destinations Artifact | ||
| uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.6.0 | ||
| with: | ||
| name: browser-destinations-${{ github.ref_name == 'staging' && 'stage' || 'production' }}-${{ github.sha }} | ||
| path: packages/browser-destinations/dist/web/ | ||
|
Comment on lines
+111
to
+112
|
||
| if-no-files-found: error | ||
| retention-days: 7 | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.