Skip to content

Commit 9dfb60a

Browse files
author
Jose Diaz-Gonzalez
committed
refactor: use common dokku/ci-docker-image for managing pushes
This will allow us to support alternative CI systems by using the same image.
1 parent e88c56f commit 9dfb60a

File tree

15 files changed

+63
-172
lines changed

15 files changed

+63
-172
lines changed

.github/linters/.yamllint.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length: disable
Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,6 @@ jobs:
2828
config: '.github/linters/.markdown-lint.yml'
2929
args: './README.md'
3030

31-
shellcheck:
32-
name: shellcheck
33-
runs-on: ubuntu-20.04
34-
steps:
35-
- name: Clone
36-
uses: actions/checkout@v2
37-
- name: Run shellcheck
38-
uses: ludeeus/action-shellcheck@d586102c117f97e63d7e3b56629d269efc9a7c60
39-
# 1.0.0 => d586102c117f97e63d7e3b56629d269efc9a7c60
40-
41-
shfmt:
42-
name: shfmt
43-
runs-on: ubuntu-20.04
44-
steps:
45-
- name: Clone
46-
uses: actions/checkout@v2
47-
- name: Run shfmt
48-
uses: luizm/action-sh-checker@802b81f66b6c31ea423aa41ad4f49f4b7b869272
49-
# v0.1.8 => 802b81f66b6c31ea423aa41ad4f49f4b7b869272
50-
env:
51-
SHFMT_OPTS: -l -d -i 2
52-
with:
53-
sh_checker_shellcheck_disable: true
54-
5531
yamllint:
5632
name: yamllint
5733
runs-on: ubuntu-20.04
@@ -61,3 +37,5 @@ jobs:
6137
- name: Run yamllint
6238
uses: ibiqlik/action-yamllint@b2aeacc1b7eeb8c23e84bba320d04fb5d6a323ee
6339
# v3.0.0 => b2aeacc1b7eeb8c23e84bba320d04fb5d6a323ee
40+
with:
41+
config_file: '.github/linters/.yamllint.yml'

Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
FROM alpine:3.12.1
2-
3-
RUN apk --no-cache add git==2.26.2-r0 openssh==8.3_p1-r0 && \
4-
mkdir -p ~/.ssh
5-
6-
COPY bin /bin
1+
FROM dokku/ci-docker-image:0.0.7

README.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,24 @@ Please note that this action is compatible with `dokku >= 0.11.6`.
1212

1313
__Optional__. The branch to deploy when pushing to Dokku (default to `master`). Useful when a [custom deploy branch](http://dokku.viewdocs.io/dokku/deployment/methods/git/#changing-the-deploy-branch) is set on Dokku.
1414

15+
Example Value: `main`
16+
17+
### `ci_branch_name`
18+
19+
__Optional__. The branch name that triggered the deploy. Automatically detected from `GITHUB_REF`.
20+
1521
Example Value: `develop`
1622

23+
### `command`
24+
25+
__Optional__. The command to run for the action (default: deploy).
26+
27+
Valid Values:
28+
29+
- `deploy`
30+
- `review-apps:create`: Used to create a review app - via `dokku apps:clone` - based on the `appname` configured in the `git_remote_url`. If the review app already exists, this action will not recreate the app. In both cases, the current commit will be pushed to the review app.
31+
- `review-apps:destroy`: Destroys an existing review app.
32+
1733
### `git_push_flags`
1834

1935
__Optional__. A string containing a set of flags to set on push. This may be used to enable force pushes, or trigger verbose log output from git.
@@ -26,6 +42,15 @@ Example Value: `--force -vvv`
2642

2743
Example Value: `ssh://dokku@dokku.myhost.ca:22/appname`
2844

45+
### `review_app_name`
46+
47+
__Optional__. The name of the review app to create or destroy. Computed as `review-$APPNAME-$BRANCH_NAME` if not specified, where:
48+
49+
- `$APPNAME`: The parsed app name from the `git_remote_url`
50+
- `$BRANCH_NAME`: The inflected git branch name
51+
52+
Example Value: `review-appname`
53+
2954
### `ssh_host_key`
3055

3156
__Optional__. The results of running `ssh-keyscan -t rsa $HOST`. The github-action will otherwise generate this on the fly via `ssh-keyscan`.
@@ -55,30 +80,6 @@ zrrvVLniH+UTjreQkhbFVqLPnL44+LIo30/oQJPISLxMYmZnuwudPN6O6ubyb8MK
5580
-----END OPENSSH PRIVATE KEY-----
5681
```
5782

58-
## Arguments
59-
60-
Arguments are optional, but may change the behavior of the action when specified. The following are the currently supported arguments and examples on how to specify them.
61-
62-
### `review-apps:create`
63-
64-
Used to create a review app - via `dokku apps:clone` - based on the `appname` configured in the `git_remote_url`. If the review app already exists, this action will not recreate the app. In both cases, the current commit will be pushed to the review app. Takes a second required argument as the name of the review app to create.
65-
66-
Example:
67-
68-
```yaml
69-
args: review-apps:create appname-${{ github.event.pull_request.number }}
70-
```
71-
72-
### `review-apps:destroy`
73-
74-
Destroys a review app. Takes a second required argument as the name of the review app to destroy.
75-
76-
Example:
77-
78-
```yaml
79-
args: review-apps:destroy appname-${{ github.event.pull_request.number }}
80-
```
81-
8283
## Examples
8384

8485
All examples below are functionally complete and can be copy-pasted into a `.github/workflows/deploy.yaml` file, with some minor caveats:

action.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,29 @@ inputs:
99
branch:
1010
description: 'The branch to deploy when pushing to Dokku (default: master)'
1111
required: false
12-
default: "master"
12+
default: 'master'
13+
ci_branch_name:
14+
description: 'The command to run for the action (default: deploy)'
15+
required: false
16+
default: ''
17+
command:
18+
description: 'The command to run for the action (default: deploy)'
19+
required: false
20+
default: 'deploy'
1321
git_push_flags:
14-
description: "The dokku app's git repository url (in SSH format)"
22+
description: 'The dokku app's git repository url (in SSH format)''
1523
required: true
1624
git_remote_url:
17-
description: "A string containing a set of flags to set on push"
25+
description: 'A string containing a set of flags to set on push'
26+
required: false
27+
review_app_name:
28+
description: 'The name of the review app to create or destroy'
1829
required: false
30+
default: ''
1931
ssh_host_key:
20-
description: 'The results of running ssh-keyscan -t rsa $HOST.'
32+
description: 'The results of running `ssh-keyscan -t rsa $HOST`'
2133
required: false
22-
default: ""
34+
default: ''
2335
ssh_private_key:
2436
description: 'A private SSH key that has push acces to your Dokku instance'
2537
required: true
@@ -31,7 +43,10 @@ runs:
3143
post-if: cancelled()
3244
env:
3345
BRANCH: ${{ inputs.branch }}
46+
CI_BRANCH_NAME: ${{ inputs.ci_branch_name }}
47+
COMMAND: ${{ inputs.command }}
3448
GIT_PUSH_FLAGS: ${{ inputs.git_push_flags }}
3549
GIT_REMOTE_URL: ${{ inputs.git_remote_url }}
50+
REVIEW_APP_NAME: ${{ inputs.review_app_name }}
3651
SSH_HOST_KEY: ${{ inputs.ssh_host_key }}
3752
SSH_PRIVATE_KEY: ${{ inputs.ssh_private_key }}

bin/dokku-deploy

Lines changed: 0 additions & 42 deletions
This file was deleted.

bin/dokku-unlock

Lines changed: 0 additions & 12 deletions
This file was deleted.

bin/log-error

Lines changed: 0 additions & 5 deletions
This file was deleted.

bin/log-info

Lines changed: 0 additions & 6 deletions
This file was deleted.

bin/parse-app-name

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)