Skip to content

Commit

Permalink
Merged to main
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyscholl authored Sep 13, 2024
2 parents 3814ab7 + e66dad4 commit 15bf7c7
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 33 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Pipeline
on: [push]
jobs:
pipeline:
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
statuses: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main

- name: Super-linter
uses: super-linter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.WF_TOKEN }}
VALIDATE_BASH: false
VALIDATE_CHECKOV: false
FIX_MARKDOWN: true
FIX_MARKDOWN_PRETTIER: true
FIX_NATURAL_LANGUAGE: true
FIX_SHELL_SHFMT: true
FIX_YAML_PRETTIER: true

- name: Commit linting fixes
if: github.ref_name != 'main'
run: |
git config --global user.email "[email protected]"
git config --global user.name "Wesley Scholl"
git add -A
git commit -m "chore: fix linting issues"
env:
GITHUB_TOKEN: ${{ secrets.WF_TOKEN }}

- name: Commit and push linting fixes
if: github.ref_name != 'main'
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: ${{ github.ref_name }}
commit_message: "chore: fix linting issues"
commit_user_name: Wesley Scholl
commit_user_email: [email protected]

- name: Merge branch
uses: julbme/gh-action-merge-branch@v1
with:
from: ${{ github.ref_name }}
to: main
message: Merged to main
push_options: '--force'
skip_fetch: true
env:
GITHUB_TOKEN: ${{ secrets.WF_TOKEN }}
63 changes: 36 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@
Manually typing staging, commit messages, and push commands is repetative. Especially copying the ticket number into the commit message. Save time using this shell script.

## Table of Contents
* [What this script automates](#what-this-script-automates)
* [User input required](#user-input-required)
* [Requirements](#requirements)
* [Installation](#installation)
* [Usage](#usage)
* [License](#license)

## What this script automates:

| Name | Description |
| --- | --- |
| Git Staging | Staging any modified files for commit using `git add -A`. |

- [What this script automates](#what-this-script-automates)
- [User input required](#user-input-required)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)

## What this script automates

| Name | Description |
| ------------------ | -------------------------------------------------------------------------------------------------- |
| Git Staging | Staging any modified files for commit using `git add -A`. |
| Git Commit Message | Copying the ticket number of the Jira ticket as the commit message prefix. Example: `[CRS-12345]`. |
| Git Commit | Committing staged files with the commit message using `git commit -S -m "<commit message>"`. |
| Git Push | Pushing local commits to remote branch with `git push`. |
| Git Commit | Committing staged files with the commit message using `git commit -S -m "<commit message>"`. |
| Git Push | Pushing local commits to remote branch with `git push`. |

## User input required:
## User input required

| Name | Description |
| --- | --- |
| Alias Command | The alias command to be used for the script: `cm`. |
| Name | Description |
| -------------- | -------------------------------------------------------- |
| Alias Command | The alias command to be used for the script: `cm`. |
| Commit Message | The commit message with description of the changes made. |

## Requirements

| Name | Description | Link, Location, or Command |
| --- | --- | --- |
| Terminal or Shell | A terminal or shell for configuring and running the script. | [Download Terminal](https://www.apple.com/macos/terminal/) |
| `Git Bash` ***Required for Windows** | Git Bash provides a UNIX command line emulator for windows which can be used to run Git, shell commands, and much more. | [Download Git Bash](https://gitforwindows.org/) |

| Name | Description | Link, Location, or Command |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| Terminal or Shell | A terminal or shell for configuring and running the script. | [Download Terminal](https://www.apple.com/macos/terminal/) |
| `Git Bash` **\*Required for Windows** | Git Bash provides a Unix command line emulator for windows which can be used to run Git, shell commands, and much more. | [Download Git Bash](https://gitforwindows.org/) |

## Installation

1. Clone the git-commit-push-script repository to your local computer.
1. Clone the git-commit-push-script repository to your local computer.

```shell
git clone https://github.com/wesleyscholl/git-commit-push-script.git
Expand All @@ -49,16 +49,19 @@ cd git-commit-push-script
```

3. Make the script executable by running the following command:

```shell
chmod +x git-commit-push-script.sh
```

4. Configure the alias command for the script in zshrc or bash_profile.

```shell
alias cm='bash /path/to/git-commit-push-script/git-commit-push-script.sh'
```

5. Reload the terminal or shell configuration by running the following command:

```shell
source ~/.zshrc
# OR #
Expand All @@ -74,11 +77,13 @@ cm
```

7. Enter your commit message when prompted.

```shell
Enter commit message: <Enter your commit message here>
```

8. The script will stage, commit with the ticket prefix, and push the changes to the remote branch.

```shell
Enter commit message: Test message
Commit message: CRS-12345 - Test message
Expand All @@ -97,16 +102,20 @@ To https://github.com/wesleyscholl/git-commit-push-script.git
## Troubleshooting

You may encounter an error from the following command because of the `-S` flag:

```shell
git commit -S -m "<commit message>"
git commit -S -m "<commit message>"
```

To resolve this error, remove the `-S` from the command in the `git-commit-push-script.sh` file:

```shell
git commit -m "<commit message>"
```

If you want to use the -S flag, configure your Git configuration to use the GPG key for signing commits.
Use the guide here: https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key
Use the guide here: <https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key>

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
12 changes: 6 additions & 6 deletions git-commit-push-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ git commit -S -m "$ticket $message"
remote_branch=$(git ls-remote --heads origin $base_branch)

if [ -z "$remote_branch" ]; then
echo "Branch '$base_branch' does not exist on remote. Creating it."
# Push the local branch to the remote, setting the upstream branch
git push --set-upstream origin $base_branch
echo "Branch '$base_branch' does not exist on remote. Creating it."
# Push the local branch to the remote, setting the upstream branch
git push --set-upstream origin $base_branch
else
echo "Branch '$base_branch' exists on remote. Pushing changes."
# Push changes to the remote
git push
echo "Branch '$base_branch' exists on remote. Pushing changes."
# Push changes to the remote
git push
fi
13 changes: 13 additions & 0 deletions super-linter-output/super-linter-summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Super-linter summary

| Language | Validation result |
| ----------------- | ----------------- |
| BASH_EXEC | Pass βœ… |
| GITLEAKS | Pass βœ… |
| JSCPD | Pass βœ… |
| MARKDOWN | Pass βœ… |
| MARKDOWN_PRETTIER | Pass βœ… |
| NATURAL_LANGUAGE | Pass βœ… |
| SHELL_SHFMT | Pass βœ… |

All files and directories linted successfully

0 comments on commit 15bf7c7

Please sign in to comment.