mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-07-30 03:09:50 +08:00
89 lines
3.7 KiB
YAML
89 lines
3.7 KiB
YAML
# Syncs @salesforce/webapp-template-app-react-sample-b2e-experimental into
|
|
# samples/webapp-template-app-react-sample-b2e-experimental. Opens a PR only when
|
|
# the npm package version has changed. Same steps as running locally:
|
|
# npm install && npm run sync-react-b2e-sample
|
|
#
|
|
# Uses IDEE_GH_TOKEN (bot) for checkout and PR creation; same pattern as
|
|
# salesforcedx-vscode-einstein-gpt/.github/workflows/build.yml
|
|
|
|
name: Sync React B2E sample from npm
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
# Nightly at 02:00 UTC
|
|
- cron: "0 2 * * *"
|
|
|
|
jobs:
|
|
sync:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
token: ${{ secrets.IDEE_GH_TOKEN }}
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: ".nvmrc"
|
|
cache: npm
|
|
|
|
- name: Configure Git for private repo access
|
|
run: |
|
|
git config --global --add url."https://${{ secrets.IDEE_GH_TOKEN }}@github.com/".insteadOf "https://github.com/"
|
|
git config --global --add url."https://${{ secrets.IDEE_GH_TOKEN }}@github.com/".insteadOf "git@github.com:"
|
|
git config --global --add url."https://${{ secrets.IDEE_GH_TOKEN }}@github.com/".insteadOf "ssh://git@github.com/"
|
|
|
|
- name: Get latest npm version
|
|
id: npm-version
|
|
run: |
|
|
LATEST=$(npm view @salesforce/webapp-template-app-react-sample-b2e-experimental version)
|
|
echo "latest=$LATEST" >> $GITHUB_OUTPUT
|
|
|
|
- name: Read current synced version
|
|
id: current-version
|
|
run: |
|
|
VERSION_FILE="samples/webapp-template-app-react-sample-b2e-experimental/.version"
|
|
if [ -f "$VERSION_FILE" ]; then
|
|
CURRENT=$(cat "$VERSION_FILE" | tr -d '[:space:]')
|
|
echo "current=$CURRENT" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "current=" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Skip if version unchanged
|
|
id: skip
|
|
run: |
|
|
if [ "${{ steps.current-version.outputs.current }}" = "${{ steps.npm-version.outputs.latest }}" ]; then
|
|
echo "skip=true" >> $GITHUB_OUTPUT
|
|
echo "No version change. Current=${{ steps.current-version.outputs.current }}, Latest=${{ steps.npm-version.outputs.latest }}"
|
|
else
|
|
echo "skip=false" >> $GITHUB_OUTPUT
|
|
echo "Version change. Current=${{ steps.current-version.outputs.current }}, Latest=${{ steps.npm-version.outputs.latest }}"
|
|
fi
|
|
|
|
- name: Install dependencies and run sync (same as local)
|
|
if: steps.skip.outputs.skip != 'true'
|
|
run: |
|
|
npm install
|
|
npm run sync-react-b2e-sample
|
|
|
|
- name: Create PR on version change
|
|
if: steps.skip.outputs.skip != 'true'
|
|
uses: peter-evans/create-pull-request@v6
|
|
with:
|
|
token: ${{ secrets.IDEE_GH_TOKEN }}
|
|
branch: chore/sync-react-b2e-sample-${{ steps.npm-version.outputs.latest }}
|
|
base: main
|
|
title: "chore: sync React B2E sample from npm @ ${{ steps.npm-version.outputs.latest }}"
|
|
body: |
|
|
Synced `@salesforce/webapp-template-app-react-sample-b2e-experimental` to `samples/webapp-template-app-react-sample-b2e-experimental`.
|
|
- **Previous version:** ${{ steps.current-version.outputs.current || 'none' }}
|
|
- **New version:** ${{ steps.npm-version.outputs.latest }}
|
|
Same flow as running locally: `npm install` then `npm run sync-react-b2e-sample`.
|
|
commit-message: "chore: sync react-b2e-sample from npm @ ${{ steps.npm-version.outputs.latest }}"
|
|
committer: svc-idee-bot <svc_idee_bot@salesforce.com>
|
|
author: svc-idee-bot <svc_idee_bot@salesforce.com>
|