Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 841bc4e805 | |||
| cb16418b18 | |||
| c045cd21a1 | |||
| a9d1874c6d | |||
| 9961990618 | |||
| cdbf90b6cb | |||
| 3532070f31 | |||
| 2794f9277d | |||
| 24f2748d1e | |||
| 645d8b7d48 | |||
| c1371a0f89 | |||
| 562d275999 | |||
| f765dad8a2 | |||
| 2e97cfb798 | |||
| a94ac16063 | |||
| d095959190 | |||
| 3453c9394d | |||
| 1c2cef08ae | |||
| f5ffd2f04c | |||
| 89fbc0403b | |||
| 5c2949e038 | |||
| b52a452408 | |||
| da6e513b3a | |||
| 3e4e529a21 | |||
| 1310f15c3d | |||
| 70db1bdc39 | |||
| 690136f592 | |||
| 72b0e8297d | |||
| 33e6c5c073 | |||
| a5cc4e5468 | |||
| ba78d9c707 | |||
| 1660ca00d2 | |||
| 88bd3eb649 | |||
| a701ca41c5 | |||
| 68af7a3b20 | |||
| ecc49a0807 |
@@ -1,7 +1,6 @@
|
|||||||
FROM alpine:3.12
|
FROM python:3.10-slim-bullseye
|
||||||
RUN apk update && apk add --no-cache bash git openssh python3 py3-pip graphviz gcc
|
|
||||||
|
|
||||||
RUN python3 -m pip install --upgrade pip setuptools wheel pyparsing pydot django-extensions django
|
|
||||||
|
|
||||||
|
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
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -7,11 +7,13 @@ A GitHub action for drawing a Django data model automatically.
|
|||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
| Parameter | Required | Default | Description |
|
| Parameter | Required | Default | Description |
|
||||||
| -------------- | :------: | :---------------: | ---------------------------------------- |
|
| -------------- | :------: | :-----------------: | ------------------------------------------------------------------ |
|
||||||
| commit_message | :x: | Added data schema | Custom git commit message |
|
| commit_message | :x: | Updated data schema | Custom git commit message |
|
||||||
| output_path | :x: | . | Output path for generated files |
|
| output_path | :x: | . | Output path for generated files (see 'Example Config' for example) |
|
||||||
| pip_path | :x: | requirements.txt | Requirements path for the Django project |
|
| pip_path | :x: | requirements.txt | Requirements path for the Django project |
|
||||||
| project_path | :x: | ./ | The path to manage.py |
|
| project_path | :x: | ./ | The path to manage.py (see 'Example Config' for example) |
|
||||||
|
|
||||||
|
> Note: The output_path has to exist already.
|
||||||
|
|
||||||
### Example Config
|
### Example Config
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ on:
|
|||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
prettier:
|
graph-models:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -37,7 +39,7 @@ jobs:
|
|||||||
ref: ${{ github.head_ref }}
|
ref: ${{ github.head_ref }}
|
||||||
|
|
||||||
- name: Generate Data Schema
|
- name: Generate Data Schema
|
||||||
uses: noah-software/django_action@v1.0
|
uses: noah-software/django_action@v1.1
|
||||||
with:
|
with:
|
||||||
# This part is also where you can pass other options, for example:
|
# This part is also where you can pass other options, for example:
|
||||||
pip_path: testfolder/app/requirements.txt
|
pip_path: testfolder/app/requirements.txt
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ inputs:
|
|||||||
commit_message:
|
commit_message:
|
||||||
description: Commit message of the changed data
|
description: Commit message of the changed data
|
||||||
required: false
|
required: false
|
||||||
default: "Added data schema"
|
default: "Updated data schema"
|
||||||
pip_path:
|
pip_path:
|
||||||
description: Path relative to the repository root, where the requirements.txt is located
|
description: Path relative to the repository root, where the requirements.txt is located
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -1,44 +1,31 @@
|
|||||||
#!/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
|
# 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
|
# x would be for showing the commands before they are executed
|
||||||
set -eu
|
set -eux
|
||||||
|
|
||||||
# FUNCTIONS
|
# 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)
|
# 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 ( ) {
|
_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.email "actions@github.com"
|
||||||
git config --global user.name "GitHub Action"
|
git config --global user.name "GitHub Action"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checks if any files are changed
|
|
||||||
_git_changed() {
|
|
||||||
[[ -n "$(git status -s)" ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
# PROGRAM
|
|
||||||
echo "Installing dependencies..."
|
echo "Installing dependencies..."
|
||||||
pip3 install --no-cache-dir -r $INPUT_PIP_PATH
|
pip3 install -U pip wheel pygraphviz
|
||||||
|
pip3 install --no-cache-dir -r "$INPUT_PIP_PATH"
|
||||||
|
|
||||||
echo "Creating data model..."
|
echo "Creating data model..."
|
||||||
cd $INPUT_PROJECT_PATH
|
cd "$INPUT_PROJECT_PATH"
|
||||||
python3 manage.py graph_models -a -g -o $INPUT_OUTPUT_PATH
|
python3 manage.py graph_models -a -g -o "$INPUT_OUTPUT_PATH"
|
||||||
|
|
||||||
# To keep runtime good, just continue if something was changed
|
# 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
|
# Calling method to configure the git environemnt
|
||||||
_git_setup
|
_git_setup
|
||||||
# Commit and push changes back
|
# 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
|
git push origin
|
||||||
echo "Changes pushed successfully."
|
echo "Changes pushed successfully."
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user