Skip to content

Commit

Permalink
Merge pull request #413 from tj-actions/chore/update-the-download
Browse files Browse the repository at this point in the history
chore/update the download
  • Loading branch information
repo-ranger[bot] committed Mar 9, 2023
2 parents 17f8357 + dc750b0 commit 0df34ae
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 10 deletions.
30 changes: 23 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ on:
pull_request:
branches:
- main
push:
tags: "**"

jobs:
snapshot:
name: snapshot
runs-on: ubuntu-latest
if: "!startsWith(github.ref, 'refs/tags/')"
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -126,44 +129,57 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Get branch name
id: branch-name
if: "startsWith(github.ref, 'refs/tags/')"
uses: tj-actions/branch-names@v6

- name: Test action
uses: ./
with:
version: ${{ steps.branch-name.outputs.tag }}

- name: Run build
if: "!startsWith(github.ref, 'refs/tags/')"
run: make build

- name: Test action with bin_path
if: "!startsWith(github.ref, 'refs/tags/')"
uses: ./
with:
bin_path: ./bin/auto_doc

- name: Run auto-doc using the test directory
if: "!startsWith(github.ref, 'refs/tags/')"
run: make test

- name: Run auto-doc using the top level directory
run: make run
if: github.event.pull_request.head.repo.owner.login == github.repository_owner
if: "!startsWith(github.ref, 'refs/tags/') && github.event.pull_request.head.repo.owner.login == github.repository_owner"

- name: Format markdown
uses: tj-actions/remark@v3
if: github.event.pull_request.head.repo.owner.login == github.repository_owner
if: "!startsWith(github.ref, 'refs/tags/') && github.event.pull_request.head.repo.owner.login == github.repository_owner"

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v13
if: github.event.pull_request.head.repo.owner.login == github.repository_owner
if: "!startsWith(github.ref, 'refs/tags/') && github.event.pull_request.head.repo.owner.login == github.repository_owner"
id: verify-changed-files
with:
files: |
README.md
test/**
- name: Commit README changes
if: github.event.pull_request.head.repo.owner.login == github.repository_owner && steps.verify-changed-files.outputs.files_changed == 'true'
if: "!startsWith(github.ref, 'refs/tags/') && github.event.pull_request.head.repo.owner.login == github.repository_owner && steps.verify-changed-files.outputs.files_changed == 'true'"
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add ${{ steps.verify-changed-files.outputs.changed_files }}
git commit -m "Updated README."
- name: Push README changes
if: github.event.pull_request.head.repo.owner.login == github.repository_owner && steps.verify-changed-files.outputs.files_changed == 'true'
if: "!startsWith(github.ref, 'refs/tags/') && github.event.pull_request.head.repo.owner.login == github.repository_owner && steps.verify-changed-files.outputs.files_changed == 'true'"
uses: ad-m/github-push-action@master
continue-on-error: true
with:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Add the `Inputs` and/or `Outputs` and/or `Secrets` [`H2` header](https://github.
| reusable\_input\_columns | string | false | | List of reusable workflow **input** column<br> names to display, default (display all<br>columns) |
| reusable\_output\_columns | string | false | | List of reusable workflow **output** column<br> names to display, default (display all<br>columns) |
| reusable\_secret\_columns | string | false | | List of reusable workflow **secret** column<br> names to display, default (display all<br>columns) |
| version | string | false | | The version number to run |

<!-- AUTO-DOC-INPUT:END -->

Expand Down
49 changes: 46 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ inputs:
reusable:
description: 'Boolean Indicating whether the file is a reusable workflow'
required: false
version:
description: 'The version number to run'
required: false

runs:
using: 'composite'
Expand All @@ -47,6 +50,7 @@ runs:
EXTRA_ARGS=""
BIN_PATH="${{ inputs.bin_path }}"
REUSABLE="${{ inputs.reusable }}"
VERSION="${{ inputs.version }}"
# action.yml file
INPUT_COLUMNS=(${{ inputs.input_columns }})
OUTPUT_COLUMNS=(${{ inputs.output_columns }})
Expand Down Expand Up @@ -85,22 +89,61 @@ runs:
for reusable_secret_column in ${REUSABLE_SECRET_COLUMNS[@]}; do
EXTRA_ARGS="${EXTRA_ARGS} --reusableSecretColumns ${reusable_secret_column}"
done
if [[ -z "$VERSION" ]]; then
VERSION=$(curl --connect-timeout 300 -svLf "https://api.github.com/repos/tj-actions/auto-doc/tags" | jq -r '.[].name' | grep -E "^v?[0-9]+\.[0-9]+\.[0-9]+$" | sort -V | tail -n 1)
fi
if [[ -z "$BIN_PATH" ]]; then
LATEST_VERSION=$VERSION
echo "Downloading auto-doc $LATEST_VERSION binary..."
# Download the latest version
WINDOWS_TARGET=Windows_x86_64
LINUX_TARGET=Linux_x86_64
MACOS_TARGET=Darwin_x86_64
ARCHIVE=zip
TEMP_DIR=$(mktemp -d)
curl -sf https://gobinaries.com/github.com/tj-actions/auto-doc | PREFIX=$TEMP_DIR sh
if [[ $(uname -s) == "Linux" ]]; then
TARGET=$LINUX_TARGET
ARCHIVE=tar.gz
elif [[ $(uname -s) == "Darwin" ]]; then
TARGET=$MACOS_TARGET
ARCHIVE=tar.gz
else
TARGET=$WINDOWS_TARGET
fi
DELAY=10
OUTPUT_FILE="$TEMP_DIR"/auto-doc."$ARCHIVE"
for i in $(seq 1 5); do
curl --connect-timeout 300 -sLf https://github.com/tj-actions/auto-doc/releases/download/"$LATEST_VERSION"/auto-doc_"${LATEST_VERSION/v/}"_"$TARGET"."$ARCHIVE" -o "$OUTPUT_FILE" && break
sleep $DELAY
echo "$i retries"
done
if [[ "$ARCHIVE" == "zip" ]]; then
unzip -q "$OUTPUT_FILE" -d "$TEMP_DIR"
else
tar -xzf "$OUTPUT_FILE" -C "$TEMP_DIR"
fi
chmod +x "$TEMP_DIR"/auto-doc
BIN_PATH="$TEMP_DIR/auto-doc"
fi
echo "::debug::Generating documentation using ${BIN_PATH}..."
echo "::debug::Extra args: ${EXTRA_ARGS}"
$BIN_PATH --filename="${{ inputs.filename }}" --output="${{ inputs.output }}" \
--colMaxWidth="${{ inputs.col_max_width }}" --colMaxWords="${{ inputs.col_max_words }}" \
${EXTRA_ARGS} && exit_status=$? || exit_status=$?
rm -f $BIN_PATH

if [[ $exit_status -ne 0 ]]; then
echo "::warning::Error occurred running auto-doc"
exit $exit_status;
Expand Down

0 comments on commit 0df34ae

Please sign in to comment.