aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/sync-examples.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/sync-examples.yml')
-rw-r--r--.github/workflows/sync-examples.yml86
1 files changed, 86 insertions, 0 deletions
diff --git a/.github/workflows/sync-examples.yml b/.github/workflows/sync-examples.yml
new file mode 100644
index 000000000..45d127447
--- /dev/null
+++ b/.github/workflows/sync-examples.yml
@@ -0,0 +1,86 @@
+name: Sync examples
+
+on:
+ workflow_dispatch:
+ inputs:
+ checkout-ref:
+ type: string
+ required: false
+ skip-unchanged-check:
+ type: boolean
+ default: false
+ dry-run:
+ type: boolean
+ default: false
+ push:
+ branches:
+ - main
+
+# Automatically cancel in-progress actions on the same branch
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ # Allow auto-branch-sync-action to git push
+ contents: write
+
+jobs:
+ sync:
+ name: Sync branches
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ with:
+ fetch-depth: 2 # fetch 2 to compare with previous commit for changes
+ ref: ${{ inputs.checkout-ref }}
+
+ - name: Detect changesets
+ uses: bluwy/detect-changesets-action@41d6432bd7bc24b3539228091f88879a18cee39b # v1
+ id: detect
+
+ - name: Get pre mode of changesets
+ id: pre
+ run: |
+ if [ -f ./.changeset/pre.json ]; then
+ pre_value=$(jq -r '.tag' ./.changeset/pre.json)
+ echo "value=$pre_value" >> $GITHUB_OUTPUT
+ fi
+
+ # We only do sync if there are no changesets, so we don't accidentally allow users
+ # to clone examples that may rely on unreleased code
+
+ - name: Sync stable to latest and examples/* branches
+ if: steps.detect.outputs.has-changesets == 'false' && github.ref == 'refs/heads/main' && steps.pre.outputs.value == ''
+ uses: bluwy/auto-branch-sync-action@a72b09dc60911f56a1e7093a069f24480ca3d2ab # v1.0.1
+ with:
+ map: |
+ / -> latest
+ /examples/* -> examples/*
+ skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
+ dry-run: ${{ inputs.dry-run == true }}
+
+ - name: Sync prerelease to alpha branch
+ if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == 'alpha'
+ uses: bluwy/auto-branch-sync-action@a72b09dc60911f56a1e7093a069f24480ca3d2ab # v1.0.1
+ with:
+ map: / -> alpha
+ skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
+ dry-run: ${{ inputs.dry-run == true }}
+
+ - name: Sync prerelease to beta branch
+ if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == 'beta'
+ uses: bluwy/auto-branch-sync-action@a72b09dc60911f56a1e7093a069f24480ca3d2ab # v1.0.1
+ with:
+ map: / -> beta
+ skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
+ dry-run: ${{ inputs.dry-run == true }}
+
+ - name: Sync prerelease to rc branch
+ if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == 'rc'
+ uses: bluwy/auto-branch-sync-action@a72b09dc60911f56a1e7093a069f24480ca3d2ab # v1.0.1
+ with:
+ map: / -> rc
+ skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
+ dry-run: ${{ inputs.dry-run == true }}