Skip to content

Commit

Permalink
[ci skip] Add new sync workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
edo9300 committed Dec 22, 2020
1 parent 20ae1c8 commit 85dbf24
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/commit-delta-utopia-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Delta repository generator
on:
push:
branches:
- master
jobs:
commit:
runs-on: ubuntu-latest
if: >-
!(
contains(github.event.head_commit.message, '[ci skip]') ||
contains(github.event.head_commit.message, '[skip ci]') ||
contains(github.event.head_commit.message, '[actions skip]') ||
contains(github.event.head_commit.message, '[skip actions]')
)
env:
REMOTE: ProjectIgnis/DeltaUtopia.git
DESTINATION: DeltaUtopia/script
BASE_SHA: 20200403
steps:
- uses: actions/checkout@v1
- name: Clone destination repository
run: |
cd $HOME
git clone https://${{ secrets.DEPLOY_TOKEN }}@github.com/$REMOTE
mkdir -p $DESTINATION
- name: Copy new or changed files
id: copy
run: |
ADDED=$(git diff --name-only --no-renames --diff-filter=d $BASE_SHA | grep -vP "(^|/)\..*" | grep -P "\.lua$")
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: 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
echo $GITHUB_SHA > VERSION
git config user.email "$CEMAIL"
git config user.name "$COMMITTER"
git add -A .
if [[ $(git status --porcelain) ]]; then
git commit --author="$AUTHOR <$EMAIL>" -m "$MESSAGE"
git push
fi

0 comments on commit 85dbf24

Please sign in to comment.