forked from withastro/astro
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (77 loc) · 3.07 KB
/
sync-examples.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Sync examples
on:
workflow_dispatch:
inputs:
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@v4
with:
fetch-depth: 2 # fetch 2 to compare with previous commit for changes
- name: Detect changesets
uses: bluwy/detect-changesets-action@v1
id: detect
# 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'
uses: bluwy/auto-branch-sync-action@v1
with:
map: |
/ -> latest
/examples/* -> examples/*
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'
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'
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'
uses: bluwy/auto-branch-sync-action@v1
with:
map: / -> rc
skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }}
dry-run: ${{ inputs.dry-run == true }}