0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-13 22:11:20 -05:00

Fix sync-examples workflow

This commit is contained in:
bluwy 2024-11-29 12:28:39 +08:00
parent 6031962ab5
commit 841bace5f0

View file

@ -3,6 +3,9 @@ name: Sync examples
on: on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
checkout-ref:
type: string
required: false
skip-unchanged-check: skip-unchanged-check:
type: boolean type: boolean
default: false default: false
@ -31,16 +34,25 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 2 # fetch 2 to compare with previous commit for changes fetch-depth: 2 # fetch 2 to compare with previous commit for changes
ref: ${{ inputs.checkout-ref }}
- name: Detect changesets - name: Detect changesets
uses: bluwy/detect-changesets-action@v1 uses: bluwy/detect-changesets-action@v1
id: detect 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 # 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 # to clone examples that may rely on unreleased code
- name: Sync from main branch to latest and examples/* branches - name: Sync stable to latest and examples/* branches
if: steps.detect.outputs.has-changesets == 'false' && github.ref == 'refs/heads/main' if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == ''
uses: bluwy/auto-branch-sync-action@v1 uses: bluwy/auto-branch-sync-action@v1
with: with:
map: | map: |
@ -49,38 +61,24 @@ jobs:
skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }} skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
dry-run: ${{ inputs.dry-run == true }} dry-run: ${{ inputs.dry-run == true }}
- name: Check .changeset/pre.json for matching tag - name: Sync prerelease to alpha branch
if: steps.detect.outputs.has-changesets == 'false' && github.ref == 'refs/heads/next' if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == 'alpha'
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'
uses: bluwy/auto-branch-sync-action@v1 uses: bluwy/auto-branch-sync-action@v1
with: with:
map: / -> alpha map: / -> alpha
skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }} skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
dry-run: ${{ inputs.dry-run == true }} dry-run: ${{ inputs.dry-run == true }}
- name: Sync from next branch to beta branch - name: Sync prerelease to beta branch
if: steps.detect.outputs.has-changesets == 'false' && steps.check-pre-mode.outputs.beta == 'true' if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == 'beta'
uses: bluwy/auto-branch-sync-action@v1 uses: bluwy/auto-branch-sync-action@v1
with: with:
map: / -> beta map: / -> beta
skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }} skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
dry-run: ${{ inputs.dry-run == true }} dry-run: ${{ inputs.dry-run == true }}
- name: Sync from next branch to rc branch - name: Sync prerelease to rc branch
if: steps.detect.outputs.has-changesets == 'false' && steps.check-pre-mode.outputs.rc == 'true' if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == 'rc'
uses: bluwy/auto-branch-sync-action@v1 uses: bluwy/auto-branch-sync-action@v1
with: with:
map: / -> rc map: / -> rc