7 Commits
v2.1 ... v4.1

Author SHA1 Message Date
bd58fcf50d Fixed a bug with the action path 2023-05-24 11:21:35 +02:00
8595edd403 Removed i and r default options from autopep 2023-05-24 10:50:35 +02:00
191697834d Minor Cleanup 2023-05-24 10:45:37 +02:00
6995413f33 Changed action to be based on python docker 2023-05-24 10:37:49 +02:00
b94a3d0b2b Added default github token 2023-05-24 10:37:37 +02:00
fc2267b495 Adjusted pip commands for Python 3 2022-09-28 00:09:22 +02:00
3b42b54814 Updated to Python 3 2022-09-28 00:08:11 +02:00
5 changed files with 34 additions and 10 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
# MacOS system files
.DS_Store

View File

@@ -1,6 +1,6 @@
FROM node:lts-alpine3.9
FROM python:3.11.3-slim-bullseye
RUN apk update && apk add --no-cache bash git openssh python py-pip
RUN apt update && apt install -y --no-install-recommends git
RUN pip install --no-cache-dir -q --upgrade pip
RUN pip install --no-cache-dir -q autopep8

View File

@@ -1,9 +1,15 @@
# GitHub autopep8 Action
This action uses the newly released GitHub action to automatically restyle your Python code according to [PEP-8](https://www.python.org/dev/peps/pep-0008/) using [autopep8](https://github.com/hhatto/autopep8).
[![License MIT](https://img.shields.io/github/license/creyD/autopep8_action)](https://github.com/creyD/autopep8_action/blob/master/LICENSE)
[![Latest Release](https://img.shields.io/github/v/release/creyD/autopep8_action)](https://github.com/creyD/autopep8_action/releases)
[![Contributors](https://img.shields.io/github/contributors-anon/creyD/autopep8_action)](https://github.com/creyD/autopep8_action/graphs/contributors)
[![Issues](https://img.shields.io/github/issues/creyD/autopep8_action)](https://github.com/creyD/autopep8_action/issues)
This action automatically restyles Python code according to [PEP-8](https://www.python.org/dev/peps/pep-0008/) using [autopep8](https://github.com/hhatto/autopep8).
## Usage
### Parameters
The following parameters can be used in your custom action configuration.
| Parameter | Required | Default | Description |
@@ -15,7 +21,9 @@ The following parameters can be used in your custom action configuration.
| no_commit | :x: | False | Avoid committing, if used in a pipeline |
| options | :x: | ' ' | Parameters to use with autopep8 |
| dry | :x: | false | Dry-run the action to fail when detecting PEP-8 uncompliant files, instead of automatically fixing them. |
| github_token | :x: | `${{ github.token }}` | The default [GITHUB_TOKEN](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret) or a [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)
> Note: using the same_commit option may lead to problems if other actions are relying on the commit being the same before and after the prettier action has ran. Keep this in mind.
### Example
@@ -36,16 +44,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
- uses: creyD/action_autopep8@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: creyD/action_autopep8@v3.1
```
More documentation for writing a workflow can be found [here](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions).
## Issues
Please report all bugs and feature request using the [GitHub issues function](https://github.com/creyD/autopep8_action/issues/new).
@@ -54,3 +61,6 @@ Please report all bugs and feature request using the [GitHub issues function](ht
- Hideo Hattori [(GitHub)](https://github.com/hhatto) for creating and maintaining autopep8
- Stefan Zweifel [(GitHub)](https://github.com/stefanzweifel) for providing an action to commit and push a git change
If you want you may also use my [autoflake](https://github.com/creyD/autoflake_action) and [prettier](https://github.com/creyD/prettier_action) GitHub actions.

View File

@@ -31,6 +31,10 @@ inputs:
description: Can be used to avoid committing the changes
required: false
default: false
github_token:
description: GitHub Token or PAT token used to authenticate against a repository
required: false
default: ${{ github.token }}
runs:
using: 'docker'

View File

@@ -2,6 +2,7 @@
# 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
shopt -s globstar
# 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)
@@ -25,8 +26,13 @@ _git_changed() {
[[ -n "$(git status -s)" ]]
}
_git_changes() {
git diff
}
# PROGRAM
echo "Running autopep8..."
autopep8 -i -r $INPUT_CHECKPATH $INPUT_OPTIONS || echo "Problem running autopep8!"
autopep8 $INPUT_CHECKPATH $INPUT_OPTIONS || echo "Problem running autopep8!"
if $INPUT_NO_COMMIT; then
exit 0
@@ -35,7 +41,9 @@ fi
if _git_changed;
then
if $INPUT_DRY; then
echo "Found non-compliant files!"
echo "Found non-compliant files:"
_git_changes
echo "Finishing dry-run. Exiting before committing."
exit 1
else
# Calling method to configure the git environemnt