generated from actions/container-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·34 lines (25 loc) · 966 Bytes
/
entrypoint.sh
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
#!/bin/bash
set -eu
REPO_FULLNAME=$(jq -r ".repository.full_name" "$GITHUB_EVENT_PATH")
echo "## Initializing git repo..."
git init
echo "### Adding git remote..."
git remote add origin https://x-access-token:[email protected]/$REPO_FULLNAME.git
echo "### Getting branch"
BRANCH=${GITHUB_REF#*refs/heads/}
echo "### git fetch $BRANCH ..."
git fetch origin $BRANCH
echo "### Branch: $BRANCH (ref: $GITHUB_REF )"
git checkout $BRANCH
echo "## Configuring git author..."
git config --global user.email "[email protected]"
git config --global user.name "Black Formatter for Python"
# Ignore workflow files (we may not touch them)
git update-index --assume-unchanged .github/workflows/*
echo "## Running black on Python source"
SRC=$(git ls-tree --full-tree -r HEAD | grep -e "\.\(py\|pyi\)\$" | cut -f 2)
black $SRC
echo "## Commiting files..."
git commit -a -m "Format Python code" || true
echo "## Pushing to $BRANCH"
git push -u origin $BRANCH