Skip to content

Commit

Permalink
fix: remove use_ssh flag
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Remove `use_ssh`. Documentation is in place to deploy using SSH keys
  • Loading branch information
woile committed Mar 3, 2023
1 parent cd3c00a commit 5fdf7c0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 11 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ RUN set -eux; \
gpg \
alpine-sdk \
bash \
openssh \
libffi-dev \
;
COPY entrypoint.sh /entrypoint.sh
Expand Down
45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ jobs:

| Name | Description | Default |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| `github_token` | Token for the repo. Can be passed in using `${{ secrets.GITHUB_TOKEN }}`. Required if `use_ssh: false` | - |
| `use_ssh` | Set to true if ssh-key has been configured for the `actions/checkout` | `false` |
| `github_token` | Token for the repo. Can be passed in using `${{ secrets.GITHUB_TOKEN }}`. Required if `push: true` | - |
| `dry_run` | Run without creating commit, output to stdout | false |
| `repository` | Repository name to push. Default or empty value represents current github repository | current one |
| `branch` | Destination branch to push changes | Same as the one executing the action by default |
Expand Down Expand Up @@ -119,11 +118,49 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
ssh-key: '${{ secrets.COMMIT_KEY }}'
ssh-key: "${{ secrets.COMMIT_KEY }}"
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
use_ssh: true
push: false
- name: Push using ssh
run: |
git push origin main --tags
```

## Creating a Github release

```yaml
name: Bump version

on:
push:
branches:
- main

jobs:
bump-version:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
name: "Bump version and create changelog with commitizen"
steps:
- name: Check out
uses: actions/checkout@v3
with:
fetch-depth: 0
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
changelog_increment_filename: body.md
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: "body.md"
tag_name: ${{ env.REVISION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

## Troubleshooting
Expand Down
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ inputs:
github_token:
description: 'Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}'
required: false
use_ssh:
description: 'Set to true if ssh-key has been configured for the actions/checkout'
required: false
default: "false"
repository:
description: 'Repository name to push. Default or empty value represents current github repository (${GITHUB_REPOSITORY})'
default: ''
Expand Down
5 changes: 3 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set -e
gpg --version
git --version

if [[ -z $INPUT_GITHUB_TOKEN && $INPUT_USE_SSH != "true" ]]; then
echo 'Missing input "github_token: ${{ secrets.GITHUB_TOKEN }}" or "use_ssh", choose one.' >&2
if [[ -z $INPUT_GITHUB_TOKEN && $INPUT_PUSH == "true" ]]; then
echo 'Missing input "github_token: ${{ secrets.GITHUB_TOKEN }}" which is required to push.' >&2
exit 1
fi

Expand Down Expand Up @@ -95,6 +95,7 @@ if [[ $INPUT_PUSH == 'true' ]]; then
elif [[ $INPUT_USE_SSH == "true" ]]; then
echo "Pushing to branch using SSH..."
REMOTE_REPO="git@github.com:${INPUT_REPOSITORY}.git"
echo "Remote repo: ${REMOTE_REPO}"
git push "$REMOTE_REPO" "HEAD:${INPUT_BRANCH}" --tags
else
echo "Pushing to branch..."
Expand Down

0 comments on commit 5fdf7c0

Please sign in to comment.