-
Notifications
You must be signed in to change notification settings - Fork 1
56 lines (46 loc) · 1.5 KB
/
deploy.yml
File metadata and controls
56 lines (46 loc) · 1.5 KB
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
name: Sync main to deploy
on:
push:
branches:
- main
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Save files from deploy branch
run: |
git fetch origin deploy || echo "No deploy branch yet"
TEMP_DIR="$RUNNER_TEMP/deploytemp"
mkdir -p "$TEMP_DIR"
if git ls-remote --exit-code origin deploy; then
for file in fly.toml .dockerignore; do
git checkout origin/deploy -- "$file" 2>/dev/null || echo "No $file to copy"
[ -f "$file" ] && cp "$file" "$TEMP_DIR/" || echo "$file not found"
done
fi
- name: Create/overwrite deploy branch
run: |
git checkout -B deploy
git reset --hard main
- name: Restore files
run: |
TEMP_DIR="$RUNNER_TEMP/deploytemp"
for file in fly.toml .dockerignore; do
if [ -f "$TEMP_DIR/$file" ]; then
cp "$TEMP_DIR/$file" "$file"
fi
done
- name: Commit and push to deploy
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Sync main -> deploy (keeping fly.toml and .dockerignore)" || echo "No changes to commit"
git push -f origin deploy