Skip to content

Commit

Permalink
Merge pull request #31 from devops-infra/feature/gh-enterprise
Browse files Browse the repository at this point in the history
Introduce organization_domain input
  • Loading branch information
ChristophShyper authored Feb 18, 2022
2 parents cf7ddb1 + ddc701c commit 1a3139b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ RUN set -eux \
chmod +x /entrypoint.sh ;\
apk update --no-cache ;\
apk add --no-cache \
bash~=5.1.8 \
bash~=5.1.16 \
git~=2.34.1 \
git-lfs~=3.0.2 ;\
rm -rf /var/cache/* ;\
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
phony: help

# Release tag for the action
VERSION := v0.5
VERSION := v0.6

# GitHub Actions bogus variables
GITHUB_REF ?= refs/heads/null
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ Features:
```
| Input Variable | Required | Default | Description |
| -------------- | -------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------- |
| github_token | Yes | `""` | Personal Access Token for GitHub for pushing the code. |
| add_timestamp | No | `false` | Whether to add the timestamp to a new branch name. Used when `target_branch` is set. Uses format `%Y-%m-%dT%H-%M-%SZ`. |
| commit_prefix | No | `[AUTO-COMMIT]` | Prefix added to commit message. If `commit_message` is not used. |
| commit_message | No | `""` | Full commit message to set. |
| force | No | `false` | Whether to use force push for fast-forward changes. Use only if necessary. |
| target_branch | No | *current branch* | Name of a new branch to push the code into. Creates branch if not existing. |
| Input Variable | Required | Default | Description |
| ------------------- | -------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------- |
| github_token | Yes | `""` | Personal Access Token for GitHub for pushing the code. |
| add_timestamp | No | `false` | Whether to add the timestamp to a new branch name. Used when `target_branch` is set. Uses format `%Y-%m-%dT%H-%M-%SZ`. |
| commit_prefix | No | `[AUTO-COMMIT]` | Prefix added to commit message. If `commit_message` is not used. |
| commit_message | No | `""` | Full commit message to set. |
| force | No | `false` | Whether to use force push for fast-forward changes. Use only if necessary. |
| organization_domain | No | `github.com` | Github Enterprise domain name. |
| target_branch | No | *current branch* | Name of a new branch to push the code into. Creates branch if not existing. |

| Outputs | Description |
| ------------- | ------------------------------------------------------------------------ |
Expand All @@ -79,7 +80,7 @@ jobs:
run: |
find . -type f -name "*" -print0 | xargs -0 sed -i "s/foo/bar/g"
- name: Commit and push changes
uses: devops-infra/action-commit-push@v0.5
uses: devops-infra/action-commit-push@v0.6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: Replaced foo with bar
Expand All @@ -100,7 +101,7 @@ jobs:
run: |
find . -type f -name "*" -print0 | xargs -0 sed -i "s/foo/bar/g"
- name: Commit and push changes
uses: devops-infra/action-commit-push@v0.5
uses: devops-infra/action-commit-push@v0.6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_prefix: "[AUTO-COMMIT] foo/bar replace"
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
description: Whether to force push
required: false
default: "false"
organization_domain:
description: Name of GitHub Enterprise organization
required: false
default: github.com
target_branch:
description: Name of a new branch to push the code into
required: false
Expand All @@ -33,7 +37,7 @@ outputs:
description: Name of the branch code was pushed into
runs:
using: docker
image: docker://devopsinfra/action-commit-push:v0.5
image: docker://devopsinfra/action-commit-push:v0.6
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
branding:
Expand Down
15 changes: 8 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ set -e
RET_CODE=0

echo "Inputs:"
echo " commit_prefix: ${INPUT_COMMIT_PREFIX}"
echo " commit_message: ${INPUT_COMMIT_MESSAGE}"
echo " target_branch: ${INPUT_TARGET_BRANCH}"
echo " add_timestamp: ${INPUT_ADD_TIMESTAMP}"
echo " force: ${INPUT_FORCE}"
echo " commit_prefix: ${INPUT_COMMIT_PREFIX}"
echo " commit_message: ${INPUT_COMMIT_MESSAGE}"
echo " target_branch: ${INPUT_TARGET_BRANCH}"
echo " add_timestamp: ${INPUT_ADD_TIMESTAMP}"
echo " organization_domain: ${INPUT_ORG_DOMAIN}"
echo " force: ${INPUT_FORCE}"

# Require github_token
if [[ -z "${GITHUB_TOKEN}" ]]; then
Expand Down Expand Up @@ -47,9 +48,9 @@ if [[ (-n "${INPUT_TARGET_BRANCH}" || "${INPUT_ADD_TIMESTAMP}" == "true") && -n
fi

# Set git credentials
git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}"
git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@${INPUT_ORG_DOMAIN}/${GITHUB_REPOSITORY}"
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.${INPUT_ORG_DOMAIN}"

# Create an auto commit
if [[ -n ${FILES_CHANGED} ]]; then
Expand Down

0 comments on commit 1a3139b

Please sign in to comment.