Skip to content

Commit 5d45204

Browse files
committed
🆕 add workflow
1 parent 9ebd7ac commit 5d45204

6 files changed

Lines changed: 169 additions & 1 deletion

File tree

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM ruby:2.6-alpine
2+
3+
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
4+
apk add --no-cache \
5+
git \
6+
hub \
7+
bash \
8+
git-subtree \
9+
libxml2-dev \
10+
curl-dev \
11+
make \
12+
gcc \
13+
libc-dev \
14+
g++ \
15+
python3-dev \
16+
imagemagick6-dev \
17+
mariadb-dev
18+
19+
COPY entrypoint.sh /entrypoint.sh
20+
RUN chmod +x /entrypoint.sh
21+
22+
ENTRYPOINT ["/entrypoint.sh"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 supermanner
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
1-
# pull_request_on_bundle_update-
1+
# Pull request on bundle update
2+
This Github Action is that send pull request on bundle update.
3+
To draw bundle update diff table, I'd like use [bundler-diff](https://github.com/sinsoku/bundler-diff), Thank you.
4+
5+
This Github Action is running on **[ruby2.6-alipne](https://github.com/docker-library/ruby/blob/5c9e21cbf79b7f36d505555c9ecd62cf0f7e07f8/2.6/alpine3.10/Dockerfile)**.
6+
7+
## Usage
8+
※ Without Gemfile and Gemfile.lock, this workflow is failure.
9+
10+
```
11+
name: pull request on bundle update
12+
on:
13+
schedule:
14+
- cron: '*/15 * * * *'
15+
16+
jobs:
17+
bundle-update:
18+
name: bundle update
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v1
23+
with:
24+
fetch-depth: 1
25+
- name: pull request on bundle update
26+
uses: supermanner/pull-request-on-bundle-update@master
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
git_user_name: example_name
30+
git_email: test@example.com
31+
reviewers: supermanner,hoge,fuga
32+
```
33+
34+
## Demo
35+
![DEMO](./images/demo.jpg)
36+
37+
## Contributing
38+
Bug reports and pull requests are welcome on GitHub at [pull-request-on-bundle-update](https://github.com/supermanner/pull-request-on-bundle-update).
39+
40+
## License
41+
The plugin is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

action.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: pull request on bundle update
2+
description: bundle update and pull request
3+
branding:
4+
icon: 'git-pull-request'
5+
color: 'green'
6+
inputs:
7+
github_token:
8+
description: github token
9+
required: true
10+
git_user_name:
11+
description: user name who git push bundle update commit
12+
required: true
13+
git_email:
14+
description: email of user who git push bundle update commit
15+
required: true
16+
reviewers:
17+
description: assigned user as a revierer
18+
required: false
19+
runs:
20+
using: 'docker'
21+
image: 'Dockerfile'
22+
env:
23+
GITHUB_TOKEN: ${{ inputs.github_token }}
24+
GIT_USER_NAME: ${{ inputs.git_user_name }}
25+
GIT_EMAIL: ${{ inputs.git_email }}

entrypoint.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash -l
2+
3+
set -e
4+
5+
if [[ -z "$GITHUB_TOKEN" ]]; then
6+
echo "Required the GITHUB_TOKEN environment variable."
7+
exit 1
8+
fi
9+
10+
if [[ -z "$GIT_USER_NAME" ]]; then
11+
echo "require to set with: GIT_USER_NAME."
12+
exit 1
13+
fi
14+
15+
if [[ -z "$GIT_EMAIL" ]]; then
16+
echo "require to set with: GIT_EMAIL."
17+
exit 1
18+
fi
19+
20+
git remote set-url origin "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY"
21+
git checkout master
22+
BRANCH_NAME="bundle_update/$(date "+%Y%m%d_%H%M%S")"
23+
git checkout -b ${BRANCH_NAME}
24+
25+
export PATH="/usr/local/bundle/bin:$PATH"
26+
27+
gem install bundler
28+
gem install bundler-diff
29+
30+
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"
31+
bundle update
32+
bundle diff -f md_table
33+
BUNDLE_DIFF="$(bundle diff -f md_table)"
34+
35+
if [ "$(git diff --name-only origin/master --diff-filter=d | wc -w)" == 0 ]; then
36+
echo "not update"
37+
exit 1
38+
fi
39+
40+
export GITHUB_USER="$GITHUB_ACTOR"
41+
42+
git config --global user.name $GIT_USER_NAME
43+
git config --global user.email $GIT_EMAIL
44+
45+
hub add Gemfile Gemfile.lock
46+
hub commit -m "bundle update && bundle update --ruby"
47+
hub push origin ${BRANCH_NAME}
48+
49+
TITLE="bundle update $(date "+%Y%m%d_%H%M%S")"
50+
51+
PR_ARG="-m \"$TITLE\" -m \"$BUNDLE_DIFF\""
52+
53+
if [[ -n "$INPUT_REVIEWERS" ]]; then
54+
PR_ARG="$PR_ARG -r \"$INPUT_REVIEWERS\""
55+
fi
56+
57+
COMMAND="hub pull-request -b master -h $BRANCH_NAME --no-edit $PR_ARG || true"
58+
59+
echo "$COMMAND"
60+
sh -c "$COMMAND"

images/demo.jpg

101 KB
Loading

0 commit comments

Comments
 (0)