Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
feat: Add globalThis fork fix and github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Thilo Haas committed Aug 8, 2024
1 parent 3d26064 commit 95e5eb6
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
85 changes: 85 additions & 0 deletions .github/workflows/fork-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Sync with Original Repo

on:
schedule:
- cron: '0 0 * * *' # runs once a day at midnight
workflow_dispatch: # click the button on Github repo!

jobs:
sync-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout forked repository
uses: actions/checkout@v2
with:
repository: smartive/stencil-patched
token: ${{ secrets.GITHUB_TOKEN }}
ref: main

- name: Setup git‡
run: |
git config --global user.name 'CI-Robot'
git config --global user.email '[email protected]'
git config --global pull.rebase true
- name: Fetch forked repository tags
run: git fetch origin --tags

- name: Get latest tag from forked repo
id: get_latest_tag_origin
run: echo "::set-output name=latest_tag::$(git describe --tags $(git rev-list --tags --max-count=1))"

- name: Add original repository as remote
run: git remote add upstream https://github.com/ionic-team/stencil.git

- name: Fetch original repository tags
run: git fetch upstream --tags

- name: Get latest tag from original repo
id: get_latest_tag
run: echo "::set-output name=latest_tag::$(git describe --tags $(git rev-list --tags --max-count=1))"

- name: Checkout and merge latest tag from original repo
if: steps.get_latest_tag_origin.outputs.latest_tag != steps.get_latest_tag.outputs.latest_tag
env:
GH_TOKEN: ${{ github.token }}
run: |
git checkout ${{ steps.get_latest_tag.outputs.latest_tag }}
git checkout -B main
git pull upstream main
git push origin main
- name: Check and update package.json name field if needed
if: steps.get_latest_tag_origin.outputs.latest_tag != steps.get_latest_tag.outputs.latest_tag
env:
GH_TOKEN: ${{ github.token }}
run: |
CURRENT_NAME=$(jq -r .name package.json)
if [ "$CURRENT_NAME" = "@stencil/core" ]; then
jq '.name = "@smartive/stencil-core"' package.json > tmp.json && mv tmp.json package.json
git add package.json
git commit -m "Update package name to @smartive/stencil-core"
git push origin main
else
echo "Package name is already updated."
fi
- name: Create new tag in forked repository
if: steps.get_latest_tag_origin.outputs.latest_tag != steps.get_latest_tag.outputs.latest_tag
env:
GH_TOKEN: ${{ github.token }}
run: |
git tag ${{ steps.get_latest_tag.outputs.latest_tag }}
git push origin --tags
- name: Publish to npm
if: steps.get_latest_tag_origin.outputs.latest_tag != steps.get_latest_tag.outputs.latest_tag
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm ci
npm run install.jest
npm run build
npm version ${{ steps.get_latest_tag.outputs.latest_tag }}
npm publish
2 changes: 1 addition & 1 deletion src/client/client-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BUILD } from '@app-data';

import type * as d from '../declarations';

export const win = typeof window !== 'undefined' ? window : ({} as Window);
export const win = typeof window !== 'undefined' ? window : ((globalThis || {}) as Window);

export const doc = win.document || ({ head: {} } as Document);

Expand Down

0 comments on commit 95e5eb6

Please sign in to comment.