-
-
Notifications
You must be signed in to change notification settings - Fork 33
63 lines (63 loc) · 2.11 KB
/
commit-delta-puppet-repo.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
name: Delta repository generator - SQLite variant
on:
push:
branches:
- master
jobs:
commit:
runs-on: ubuntu-latest
env:
REMOTE: ProjectIgnis/DeltaPuppetOfStrings.git
DESTINATION: DeltaPuppetOfStrings
BASE_SHA: 20220912
steps:
- uses: actions/checkout@v1
- name: Install sqlite3
run: |
sudo apt update
sudo apt install -y sqlite3
- name: Clone destination repository
run: |
cd $HOME
git clone https://${{ secrets.DEPLOY_TOKEN }}@github.com/$REMOTE
mkdir -p $DESTINATION
- name: Copy new CDBs only
run: |
ADDED=$(git diff --name-only --no-renames --diff-filter=A $BASE_SHA | grep ".cdb$" || [[ $? == 1 ]])
if [[ "$ADDED" ]]; then
rsync -avR $ADDED $HOME/$DESTINATION
fi
- name: Remove deleted files
run: |
if [[ -f $HOME/$DESTINATION/VERSION ]]; then
LAST_SHA=$(cat $HOME/$DESTINATION/VERSION)
REMOVED=$(git diff --name-only --no-renames --diff-filter=D $LAST_SHA)
if [[ "$REMOVED" ]]; then
cd $HOME/$DESTINATION
git rm -rf --ignore-unmatch $REMOVED
fi
fi
- name: Generate SQLite deltas
run: |
CHANGED=$(git diff --name-only --diff-filter=M $BASE_SHA | grep ".cdb$" || [[ $? == 1 ]])
for DB in $CHANGED; do
./ci/sqlite3-git.sh $BASE_SHA $DB
done
find . -type f -name '*.delta.cdb' -exec rsync -avR {} $HOME/$DESTINATION \;
- name: Commit and push with original metadata
run: |
MESSAGE=$(git log -1 --pretty=%B)
AUTHOR=$(git log -1 --pretty=format:'%an')
EMAIL=$(git log -1 --pretty=format:'%ae')
COMMITTER=$(git log -1 --pretty=format'%cn')
CEMAIL=$(git log -1 --pretty=format:'%ce')
cd $HOME/$DESTINATION
git config user.email "$CEMAIL"
git config user.name "$COMMITTER"
git add -A .
if [[ $(git status --porcelain) ]]; then
echo $GITHUB_SHA > VERSION
git add -A .
git commit --author="$AUTHOR <$EMAIL>" -m "$MESSAGE"
git push
fi