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

Sync with Original Repo #283

Sync with Original Repo

Sync with Original Repo #283

Workflow file for this run

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]'
- 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: Check if latest tag is already present in forked repo
id: check_tag
run: |
if git rev-parse refs/tags/${{ steps.get_latest_tag.outputs.latest_tag }} >/dev/null 2>&1; then
echo "Tag ${{ steps.get_latest_tag.outputs.latest_tag }} already exists in forked repo."
echo "::set-output name=tag_exists::true"
else
echo "Tag ${{ steps.get_latest_tag.outputs.latest_tag }} does not exist in forked repo."
echo "::set-output name=tag_exists::false"
fi
- name: Checkout and merge latest tag from original repo
if: steps.check_tag.outputs.tag_exists == 'false'
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.check_tag.outputs.tag_exists == 'false'
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.check_tag.outputs.tag_exists == 'false'
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.check_tag.outputs.tag_exists == 'false'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm install
npm version ${{ steps.get_latest_tag.outputs.latest_tag }}
npm publish