Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f22c61866 | |||
| 841bc4e805 | |||
| a0783b9f4a | |||
| cb16418b18 | |||
| c045cd21a1 | |||
| a9d1874c6d | |||
| 9961990618 | |||
| cdbf90b6cb | |||
| 3532070f31 | |||
| 2794f9277d | |||
| 24f2748d1e | |||
| 645d8b7d48 | |||
| c1371a0f89 | |||
| 562d275999 | |||
| f765dad8a2 | |||
| 2e97cfb798 | |||
| a94ac16063 | |||
| d095959190 | |||
| 3453c9394d | |||
| 1c2cef08ae | |||
| f5ffd2f04c | |||
| 89fbc0403b | |||
| 5c2949e038 | |||
| b52a452408 | |||
| ecc49a0807 |
@@ -1,5 +1,6 @@
|
||||
FROM alpine:3.12
|
||||
RUN apk update && apk add --no-cache bash git gcc openssh python3 py3-pip graphviz graphviz-dev musl-dev postgresql-dev build-base python3-dev libffi-dev openssl-dev
|
||||
FROM python:3.10-slim-bullseye
|
||||
|
||||
RUN apt-get update -y && apt-get install -y --no-install-recommends bash git graphviz graphviz-dev musl-dev build-essential gcc && apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 noah UG
|
||||
Copyright (c) 2020 noah GmbH
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
18
README.md
18
README.md
@@ -6,12 +6,14 @@ A GitHub action for drawing a Django data model automatically.
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Required | Default | Description |
|
||||
| -------------- | :------: | :---------------: | ---------------------------------------- |
|
||||
| commit_message | :x: | Added data schema | Custom git commit message |
|
||||
| output_path | :x: | . | Output path for generated files |
|
||||
| pip_path | :x: | requirements.txt | Requirements path for the Django project |
|
||||
| project_path | :x: | ./ | The path to manage.py |
|
||||
| Parameter | Required | Default | Description |
|
||||
| -------------- | :------: | :-----------------: | ------------------------------------------------------------------ |
|
||||
| commit_message | :x: | Updated data schema | Custom git commit message |
|
||||
| output_path | :x: | . | Output path for generated files (see 'Example Config' for example) |
|
||||
| pip_path | :x: | requirements.txt | Requirements path for the Django project |
|
||||
| project_path | :x: | ./ | The path to manage.py (see 'Example Config' for example) |
|
||||
|
||||
> Note: The output_path has to exist already.
|
||||
|
||||
### Example Config
|
||||
|
||||
@@ -26,7 +28,7 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
prettier:
|
||||
graph-models:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -37,7 +39,7 @@ jobs:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
- name: Generate Data Schema
|
||||
uses: noah-software/django_action@v1.0
|
||||
uses: noah-software/django_action@v1.1
|
||||
with:
|
||||
# This part is also where you can pass other options, for example:
|
||||
pip_path: testfolder/app/requirements.txt
|
||||
|
||||
@@ -7,7 +7,7 @@ inputs:
|
||||
commit_message:
|
||||
description: Commit message of the changed data
|
||||
required: false
|
||||
default: "Added data schema"
|
||||
default: "Updated data schema"
|
||||
pip_path:
|
||||
description: Path relative to the repository root, where the requirements.txt is located
|
||||
required: false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# 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 -eux
|
||||
@@ -6,39 +6,26 @@ set -eux
|
||||
# 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..."
|
||||
pip3 install -r $INPUT_PIP_PATH
|
||||
pip3 install -U pip wheel pygraphviz
|
||||
pip3 install --no-cache-dir -r "$INPUT_PIP_PATH"
|
||||
|
||||
echo "Creating data model..."
|
||||
cd $INPUT_PROJECT_PATH
|
||||
python3 manage.py graph_models -a -g -o $INPUT_OUTPUT_PATH
|
||||
cd "$INPUT_PROJECT_PATH"
|
||||
python3 manage.py graph_models -a -g -o "$INPUT_OUTPUT_PATH"
|
||||
|
||||
# To keep runtime good, just continue if something was changed
|
||||
if _git_changed;
|
||||
then
|
||||
|
||||
if [[ `git status --porcelain` ]]; then
|
||||
# Calling method to configure the git environemnt
|
||||
_git_setup
|
||||
# Commit and push changes back
|
||||
git commit -a -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>"
|
||||
git add "$INPUT_OUTPUT_PATH"
|
||||
git commit -am "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>"
|
||||
git push origin
|
||||
echo "Changes pushed successfully."
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user