Skip to content

Commit

Permalink
Merge 598deb5 into 2c9ba9b
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Nov 7, 2021
2 parents 2c9ba9b + 598deb5 commit dbe9572
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 50 deletions.
79 changes: 69 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test-local:
name: Test auto-doc local
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v2.4.0
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token

- name: Setup go
uses: actions/setup-go@v2
with:
go-version: '1.14.4'

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run auto-doc using the current working directory
run:
make run

- name: Run auto-doc using the test directory
run:
make run ACTION="test/action.yml" OUTPUT="test/README.md"

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v8.6
id: verify-changed-files
with:
files: |
README.md
- name: Commit README changes
if: 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: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT_TOKEN }}
branch: ${{ github.head_ref }}

test:
name: Test auto-doc
if: github.event_name == 'push'
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -36,17 +93,19 @@ jobs:
files: |
README.md
- name: Commit README changes
- name: README.md changed
if: 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."
echo "README.md has uncommited changes"
exit 1
- name: Push README changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
- name: Create Pull Request
if: failure()
uses: peter-evans/create-pull-request@v3
with:
github_token: ${{ secrets.PAT_TOKEN }}
branch: ${{ github.head_ref }}
base: "main"
title: "auto-doc: Updated README.md"
branch: "chore/auto-doc-update-readme"
commit-message: "auto-doc: Updated README.md"
body: "auto-doc: Updated README.md"
token: ${{ secrets.PAT_TOKEN }}
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (a *Action) renderOutput() {
}

outputTable := tablewriter.NewWriter(outputTableOutput)
outputTable.SetHeader([]string{"Output", "Description", "Value"})
outputTable.SetHeader([]string{"Output", "Description", "Type"})
outputTable.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
outputTable.SetCenterSeparator("|")

Expand All @@ -140,7 +140,7 @@ func (a *Action) renderOutput() {
sort.Strings(keys)

for _, key := range keys {
row := []string{key, a.Outputs[key].Description, a.Outputs[key].Value}
row := []string{key, a.Outputs[key].Description, "string"}
outputTable.Append(row)
}

Expand Down
60 changes: 30 additions & 30 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@

<!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section -->

| OUTPUT | DESCRIPTION | VALUE |
|--------------------------------|--------------------------------|-------|
| added_files | List of added files. | |
| all_changed_and_modified_files | List of all changed files. | |
| all_modified_files | List of all copied modified | |
| | and added files. | |
| any_changed | Return true only when any | |
| | files provided using the files | |
| | input have changed. | |
| any_deleted | Return true only when any | |
| | files provided using the files | |
| | input have been deleted. | |
| copied_files | List of copied files. | |
| deleted_files | List of deleted files. | |
| modified_files | List of modified files. | |
| only_changed | Return true when all files | |
| | provided using the files input | |
| | have changed. | |
| only_deleted | Return true when all files | |
| | provided using the files input | |
| | have been deleted. | |
| other_changed_files | Return list of changed files | |
| | not listed in the files input. | |
| other_deleted_files | Return list of deleted files | |
| | not listed in the files input. | |
| renamed_files | List of renamed files. | |
| type_changed_files | List of files that had type | |
| | changes. | |
| unknown_files | List of unknown files. | |
| unmerged_files | List of unmerged files. | |
| OUTPUT | DESCRIPTION | TYPE |
|--------------------------------|--------------------------------|--------|
| added_files | List of added files. | string |
| all_changed_and_modified_files | List of all changed files. | string |
| all_modified_files | List of all copied modified | string |
| | and added files. | |
| any_changed | Return true only when any | string |
| | files provided using the files | |
| | input have changed. | |
| any_deleted | Return true only when any | string |
| | files provided using the files | |
| | input have been deleted. | |
| copied_files | List of copied files. | string |
| deleted_files | List of deleted files. | string |
| modified_files | List of modified files. | string |
| only_changed | Return true when all files | string |
| | provided using the files input | |
| | have changed. | |
| only_deleted | Return true when all files | string |
| | provided using the files input | |
| | have been deleted. | |
| other_changed_files | Return list of changed files | string |
| | not listed in the files input. | |
| other_deleted_files | Return list of deleted files | string |
| | not listed in the files input. | |
| renamed_files | List of renamed files. | string |
| type_changed_files | List of files that had type | string |
| | changes. | |
| unknown_files | List of unknown files. | string |
| unmerged_files | List of unmerged files. | string |

<!-- AUTO-DOC-OUTPUT:END -->
9 changes: 1 addition & 8 deletions test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ inputs:
description: 'Split character for array output'
required: true
default: " "
files_from_source_file:
description: 'Source file to populate the files input'
required: false
default: ""
files:
description: 'Check for changes using only this list of files (Defaults to the entire repo)'
required: false
Expand Down Expand Up @@ -66,9 +62,6 @@ outputs:
only_changed:
description: Return true when all files provided using the files input have changed.
value: ${{ steps.test.outputs.only_changed }}
other_changed_files:
description: Return list of changed files not listed in the files input.
value: ${{ steps.test.outputs.other_changed_files }}
any_deleted:
description: Return true only when any files provided using the files input have been deleted.
value: ${{ steps.test.outputs.any_deleted }}
Expand All @@ -88,4 +81,4 @@ runs:
shell: bash
branding:
icon: file-text
color: white
color: white

0 comments on commit dbe9572

Please sign in to comment.