Added initial action
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
.DS_Store
|
||||
4
Dockerfile
Normal file
4
Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM node:lts-alpine3.9
|
||||
RUN apk update && apk add --no-cache bash git openssh
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
4
LICENSE
4
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 noah
|
||||
Copyright (c) 2020 noah UG
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -14,7 +14,7 @@ copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
|
||||
30
action.yml
Normal file
30
action.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Django Action
|
||||
description: Automatically runs some django tasks.
|
||||
|
||||
author: Conrad Großer <conrad@noah.tech>
|
||||
|
||||
inputs:
|
||||
output_path:
|
||||
description: Output path for the generated data scheme
|
||||
required: false
|
||||
default: "./"
|
||||
commit_message:
|
||||
description: Commit message of the changed data
|
||||
required: false
|
||||
default: "Added data schema"
|
||||
file_pattern:
|
||||
description: File pattern used for `git add` command
|
||||
required: false
|
||||
default: "*"
|
||||
pip_path:
|
||||
description: Path relative to the repository root, where the requirements.txt is located
|
||||
required: false
|
||||
default: "requirements.txt"
|
||||
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
|
||||
branding:
|
||||
icon: "book"
|
||||
color: "green"
|
||||
49
entrypoint.sh
Executable file
49
entrypoint.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
# e is for exiting the script automatically if a command fails, u is for exiting if a variable is not set
|
||||
# x would be for showing the commands before they are executed
|
||||
set -eu
|
||||
|
||||
# FUNCTIONS
|
||||
# Function for setting up git env in the docker container (copied from https://github.com/stefanzweifel/git-auto-commit-action/blob/master/entrypoint.sh)
|
||||
_git_setup ( ) {
|
||||
cat <<- EOF > $HOME/.netrc
|
||||
machine github.com
|
||||
login $GITHUB_ACTOR
|
||||
password $GITHUB_TOKEN
|
||||
machine api.github.com
|
||||
login $GITHUB_ACTOR
|
||||
password $GITHUB_TOKEN
|
||||
EOF
|
||||
chmod 600 $HOME/.netrc
|
||||
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "GitHub Action"
|
||||
}
|
||||
|
||||
# Checks if any files are changed
|
||||
_git_changed() {
|
||||
[[ -n "$(git status -s)" ]]
|
||||
}
|
||||
|
||||
# PROGRAM
|
||||
echo "Installing dependencies..."
|
||||
pip install -r $pip_path
|
||||
pip install django-extensions pyparsing pydot
|
||||
echo "Creating data model..."
|
||||
python manage.py graph_models -a -g-o $output_path
|
||||
|
||||
# To keep runtime good, just continue if something was changed
|
||||
if _git_changed;
|
||||
then
|
||||
# Calling method to configure the git environemnt
|
||||
_git_setup
|
||||
echo "Commiting and pushing changes..."
|
||||
# Add changes to git
|
||||
git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}"
|
||||
# Commit and push changes back
|
||||
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
|
||||
git push origin
|
||||
echo "Changes pushed successfully."
|
||||
else
|
||||
echo "Nothing to commit. Exiting."
|
||||
fi
|
||||
Reference in New Issue
Block a user