summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Bjorn Lu <bjornlu.dev@gmail.com> 2024-12-31 20:34:17 +0800
committerGravatar GitHub <noreply@github.com> 2024-12-31 20:34:17 +0800
commitf7068995aa451dced13853789b0d51433c2373b5 (patch)
treefb30f25833112f7d1b6fd48637cca08901226ef7
parentebe2aa95c7f4a6559cec8b82d155da34a57bdd53 (diff)
downloadastro-f7068995aa451dced13853789b0d51433c2373b5.tar.gz
astro-f7068995aa451dced13853789b0d51433c2373b5.tar.zst
astro-f7068995aa451dced13853789b0d51433c2373b5.zip
Fix sync-examples workflow (#12562)
-rw-r--r--.github/workflows/sync-examples.yml42
1 files changed, 20 insertions, 22 deletions
diff --git a/.github/workflows/sync-examples.yml b/.github/workflows/sync-examples.yml
index 8603a951e..0f8d42bcc 100644
--- a/.github/workflows/sync-examples.yml
+++ b/.github/workflows/sync-examples.yml
@@ -3,6 +3,9 @@ name: Sync examples
on:
workflow_dispatch:
inputs:
+ checkout-ref:
+ type: string
+ required: false
skip-unchanged-check:
type: boolean
default: false
@@ -31,16 +34,25 @@ jobs:
uses: actions/checkout@v4
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@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 from main branch to latest and examples/* branches
- if: steps.detect.outputs.has-changesets == 'false' && github.ref == 'refs/heads/main'
+ - 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@v1
with:
map: |
@@ -49,38 +61,24 @@ jobs:
skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
dry-run: ${{ inputs.dry-run == true }}
- - name: Check .changeset/pre.json for matching tag
- if: steps.detect.outputs.has-changesets == 'false' && github.ref == 'refs/heads/next'
- id: check-pre-mode
- run: |
- if [ -f ./.changeset/pre.json ]; then
- if grep -q '"tag": "alpha"' ./.changeset/pre.json; then
- echo "alpha=true" >> $GITHUB_OUTPUT
- elif grep -q '"tag": "beta"' ./.changeset/pre.json; then
- echo "beta=true" >> $GITHUB_OUTPUT
- elif grep -q '"tag": "rc"' ./.changeset/pre.json; then
- echo "rc=true" >> $GITHUB_OUTPUT
- fi
- fi
-
- - name: Sync from next branch to alpha branch
- if: steps.detect.outputs.has-changesets == 'false' && steps.check-pre-mode.outputs.alpha == '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@v1
with:
map: / -> alpha
skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
dry-run: ${{ inputs.dry-run == true }}
- - name: Sync from next branch to beta branch
- if: steps.detect.outputs.has-changesets == 'false' && steps.check-pre-mode.outputs.beta == '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@v1
with:
map: / -> beta
skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
dry-run: ${{ inputs.dry-run == true }}
- - name: Sync from next branch to rc branch
- if: steps.detect.outputs.has-changesets == 'false' && steps.check-pre-mode.outputs.rc == '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@v1
with:
map: / -> rc