Skip to content

Commit

Permalink
Merge b6d7a0d into 17f8357
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Mar 9, 2023
2 parents 17f8357 + b6d7a0d commit 15a0102
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 10 deletions.
31 changes: 24 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,58 @@ 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
if: "startsWith(github.ref, 'refs/tags/')"
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
44 changes: 41 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 @@ -87,20 +91,54 @@ runs:
done
if [[ -z "$BIN_PATH" ]]; then
echo "Downloading auto-doc binary..."
LATEST_VERSION=${VERSION:-v2.0.0}
# Download the latest version
WINDOWS_TARGET=x86_64-pc-windows-gnu
LINUX_TARGET=x86_64-unknown-linux-musl
MACOS_TARGET=x86_64-apple-darwin
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
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/json2file/releases/download/"$LATEST_VERSION"/json2file_"$LATEST_VERSION"_"$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 15a0102

Please sign in to comment.