-
Notifications
You must be signed in to change notification settings - Fork 116
94 lines (76 loc) · 2.9 KB
/
deploy-to-stream-dist.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
89
90
91
92
93
94
name: Deploy to xwp/stream-dist Repository
on: push
jobs:
deploy_to_stream_dist:
name: Deploy to xwp/stream-dist
runs-on: ubuntu-22.04
permissions:
contents: write
packages: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup environment
run: |
set -ex
ROOT_DIR="$(git rev-parse --show-toplevel)"
WORKING_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
SRC_DIR="$ROOT_DIR/build"
DIST_DIR="$ROOT_DIR/dist"
DIST_BRANCH="${GITHUB_REF#refs/heads/}"
DIST_TAG="${GITHUB_REF#refs/tags/}"
COMMIT_MESSAGE="$(git log -1 --oneline)"
echo "ROOT_DIR=$ROOT_DIR" >> $GITHUB_ENV
echo "WORKING_BRANCH=$WORKING_BRANCH" >> $GITHUB_ENV
echo "SRC_DIR=$SRC_DIR" >> $GITHUB_ENV
echo "DIST_DIR=$DIST_DIR" >> $GITHUB_ENV
echo "DIST_BRANCH=$DIST_BRANCH" >> $GITHUB_ENV
echo "DIST_TAG=$DIST_TAG" >> $GITHUB_ENV
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
- name: Sync files locally
run: |
rm -rf "$SRC_DIR"
rm -rf "$DIST_DIR"
mkdir -p "$SRC_DIR"
rsync -av --exclude-from=.distignore "$ROOT_DIR/" "$SRC_DIR/"
env:
ROOT_DIR: ${{ env.ROOT_DIR }}
SRC_DIR: ${{ env.SRC_DIR }}
DIST_DIR: ${{ env.DIST_DIR }}
- name: Setup SSH deploy key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_DEPLOY_KEY }}
known_hosts: github.com
- name: Configure Git
run: |
git config --global user.name "XWP Deploy Bot"
git config --global user.email "[email protected]"
- name: Deploy to xwp/stream-dist
run: |
echo ${{ env.DIST_REPO }}
echo ${{ env.DIST_BRANCH }}
echo ${{ env.DIST_TAG }}
echo ${{ env.COMMIT_MESSAGE }}
echo ${{ env.DIST_DIR }}
ls -al
export GIT_DIR="$DIST_DIR/.git"
export GIT_WORK_TREE="$DIST_DIR"
git clone --progress --verbose ${{ env.DIST_REPO }} "$DIST_DIR/.git"
git checkout -B "$DIST_BRANCH"
# Use the release bundle as the work tree.
export GIT_WORK_TREE="$SRC_DIR"
git add --all
git commit --allow-empty --message "$COMMIT_MESSAGE"
if [ "${{ github.event_name }}" = "release" ]; then
echo "Tagging a release: $DIST_TAG"
git tag --force "$DIST_TAG"
git push --force --tags origin "$DIST_BRANCH"
else
git push --force origin "$DIST_BRANCH"
fi
env:
DIST_DIR: ${{ env.DIST_DIR }}
DIST_BRANCH: ${{ env.DIST_BRANCH }}
DIST_TAG: ${{ env.DIST_TAG }}
COMMIT_MESSAGE: ${{ env.COMMIT_MESSAGE }}