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
on:
push:
- workflows: [publish-install]
filter:
branches: [master]
paths: ["install.sh"]
workflows:
publish-install:
tasks:
- name: publish-install
cubes:
- name: publish
image: alpine:latest
env:
SC_TOKEN: ${{ secrets.SC_TOKEN }}
script:
- apk add --no-cache git
- |
git config user.name "CI Bot"
git config user.email "ci@sourcecraft.dev"
# Set up authenticated remote
- |
git remote set-url origin \
"https://ci:${SC_TOKEN}@git.sourcecraft.dev/bigbes/shroud.git"
# Create or update the site branch with install.sh
- |
SITE_BRANCH="site"
# Check if site branch exists remotely
if git ls-remote --exit-code origin "refs/heads/${SITE_BRANCH}" >/dev/null 2>&1; then
git fetch origin "${SITE_BRANCH}"
git checkout "${SITE_BRANCH}"
else
git checkout --orphan "${SITE_BRANCH}"
git rm -rf .
fi
# Copy install.sh from master
git show "origin/master:install.sh" > install.sh
git add install.sh
# Only commit and push if there are changes
if git diff --cached --quiet; then
echo "No install.sh changes to publish"
else
git commit -m "site: update install.sh"
git push origin "${SITE_BRANCH}"
fi