Skip to content

Commit

Permalink
Dev: Auto fetch contributors (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
NBprojekt authored Feb 2, 2022
1 parent 40e3d4c commit 75bb270
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 70 deletions.
62 changes: 1 addition & 61 deletions .github/workflows/gource-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
avatars_url: ./avatars/
gource_title: 'Gource Action Development'
logo_url: ./logo.png
avatars_auto_fetch: true

- name: 'Check output'
run: |
Expand All @@ -36,64 +37,3 @@ jobs:
name: gource-local
path: ./gource
retention-days: 1

external-images:
runs-on: ubuntu-latest

steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: 'Current folder'
run: ls -al

- name: 'Gource Action'
uses: ./
with:
git_url: ./
avatars_url: ./avatars/
gource_title: 'Gource Action Development'
logo_url: 'https://user-images.githubusercontent.com/24683383/92398226-79a40680-f128-11ea-9f54-6ccbaca4a6a5.png'

- name: 'Check output'
run: |
ls -al ./
ls -al ./gource
- uses: actions/upload-artifact@v2
with:
name: gource-external
path: ./gource
retention-days: 1

no-images:
runs-on: ubuntu-latest

steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: 'Current folder'
run: ls -al

- name: 'Gource Action'
uses: ./
with:
git_url: ./
avatars_url: ./avatars/
gource_title: 'Gource Action Development'

- name: 'Check output'
run: |
ls -al ./
ls -al ./gource
- uses: actions/upload-artifact@v2
with:
name: gource-no
path: ./gource
retention-days: 1
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ RUN \
ffmpeg \
git \
gource \
imagemagick;
imagemagick \
jq;

# Copy scripts into image
COPY ./entrypoint.sh ./gource.sh /usr/local/bin/
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ Keys can be added directly to your .yml config file or referenced from your proj
| git_url | false | ./ | Location of git repository. Can also be an remote repository e.g.: https://github.com/acaudwell/Gource.git |
| git_token | false | | If the provided repository is private, the action need an token with read scope. |
| logo_url | false | | Displayed icon on bottom right corner. Can be local "./logo.png" or Url. For Url it must be png or jgp |
| avatars_auto_fetch | false | false | Tries to fetch user avatar from all contributors. If this is enable "avatars_url" will be ignored. |
| avatars_url | false | | Path of local directory containing user avatars. |
| gource_resolution | false | 1080p | Used gource resolution (2160p, 1440p, 1080p, 720p). |
## Advanced Example
Lets use a more advanced setup to visualize the development from the [Docker CLI][docker-cli].
Expand Down Expand Up @@ -110,12 +110,13 @@ jobs:
```
> This action can take up to _17 Minutes_
## Advanced Settings
## Gource Settings
This settings are all supported setting for [gource][gource-homepage] itself.
A full list of all available options can be found [here][gource-docs].
| Key Name | Required? | Default | Description |
|--------------------------- |----------- |---------------------- |------------------------------------------------------------------------------------------------------------ |
| gource_resolution | false | 1080p | Used gource resolution (2160p, 1440p, 1080p, 720p). |
| gource_title | false | Title | Set a title. |
| gource_fps | false | 60 | Used gource fps. |
| gource_auto_skip_seconds | false | 0.5 | Skip to next entry if nothing happens for a number of seconds. |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ inputs:
description: 'Displayed icon on bottom right corner.'
default: ''
required: false
avatars_auto_fetch:
description: 'Tries to fetch user avatar from all contributors. If this is enable "avatars_url" will be ignored.'
default: 'false'
required: false
avatars_url:
description: 'Path of local directory containing user avatars.'
default: ''
Expand Down
38 changes: 32 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,41 @@ else
export FILTER_GRAPH_MAP=" -map [with_date] "
fi

# Copy user imgages if provided
printf "\n>\n> Avatars check"
if [ "${INPUT_AVATARS_URL}" != "" ]; then
printf "\n> \tCopy avatars directory: ${INPUT_AVATARS_URL}\n"
find "/github/workspace/${INPUT_AVATARS_URL}" -type f -exec cp {} /gource/avatars \;
# Auto fetch contributor avatars
printf "\n>\n> Auto fetch contributor avatars"
if [ "${INPUT_AVATARS_AUTO_FETCH}" == "true" ]; then
printf "\n> \tFetching all contributors\n"

while IFS='|' read -ra author; do
name=${author[0]}
name="${name#"${name%%[![:space:]]*}"}"
name="${name%"${name##*[![:space:]]}"}"
email=${author[1]}
# This hack removes leating and trailing spaces
email="${email#"${email%%[![:space:]]*}"}"
email="${email%"${email##*[![:space:]]}"}"

# Use github api to get avatar url using the author email
avatar=$(wget -O - -o /dev/null https://api.github.com/search/users?q=$email | jq -r '.items[0].avatar_url')
if [ "$avatar" != "null" ]; then
printf "\n> \t\tDownloading avatar for $name from: $avatar"
wget -O "/gource/avatars/$name.png" $avatar >/dev/null 2>&1
fi
done <<< "$(git --git-dir /gource/git_repo/.git log --pretty="%aN | %aE" | sort | uniq)";
else
printf "\n> \tNo avatars directory provided, skipping avatars setup\n"
printf "\n> \tAuto fetch is disabled, fall back to avatars directory\n"

# Copy user imgages if provided
printf "\n>\n> Avatars check"
if [ "${INPUT_AVATARS_URL}" != "" ]; then
printf "\n> \tCopy avatars directory: ${INPUT_AVATARS_URL}\n"
find "/github/workspace/${INPUT_AVATARS_URL}" -type f -exec cp {} /gource/avatars \;
else
printf "\n> \tNo avatars directory provided, skipping avatars setup\n"
fi
fi


# Run the visualization
printf "\n>\n> Starting gource script\n"
/usr/local/bin/gource.sh
Expand Down

0 comments on commit 75bb270

Please sign in to comment.