Skip to content

Commit

Permalink
Merge pull request #20 from reproio/feat/add-action
Browse files Browse the repository at this point in the history
support GitHub Action
  • Loading branch information
takaishi authored Aug 5, 2023
2 parents 79d6e35 + 994f0a1 commit b0a8400
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform-j2md
===
# terraform-j2md

![Go](https://github.com/reproio/terraform-j2md/workflows/Go/badge.svg)
![goreleaser](https://github.com/reproio/terraform-j2md/workflows/goreleaser/badge.svg)

Expand All @@ -11,18 +11,27 @@ _terraform-j2md_ is simple conversion tool, from Terraform JSON to Markdown text

Output texts may be useful as pull-request comments, and so on.

## How to use
## Install

```
% go install github.com/reproio/terraform-j2md/cmd/terraform-j2md@latest
```

### GitHub Actions

### Installation
(TBD)
```yaml
- uses: reproio/terraform-j2md@main
with:
version: v0.0.7 # or latest
```
### Usage
## Usage
_terraform-j2md_ reads only standard input, write only standard output.
```
terraform-j2md < [input file] > [output file]
```

### Example
## Example
````sh
$ terraform init
$ terraform plan -out plan.tfplan
Expand Down
36 changes: 36 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name:
description:
inputs:
version:
description: "A version to install terraform-j2md"
default: latest
required: false
github-token:
description: ""
required: false
default: ${{ github.token }}
runs:
using: "composite"
steps:
- shell: bash
env:
github_token: ${{ inputs.github-token }}
run: |
set -e
VERSION="${{ inputs.version }}"
if [ -n "${{ inputs.version-file }}" ]; then
VERSION="v$(cat ${{ inputs.version-file }})"
fi
api_request_args=("-sS")
if [[ -n "$github_token" ]]; then
api_request_args=("${api_request_args[@]}" -H "authorization: token $github_token")
fi
if [ "${VERSION}" = "latest" ]; then
DOWNLOAD_URL=$(curl "${api_request_args[@]}" https://api.github.com/repos/reproio/terraform-j2md/releases | jq -r '[.[] | select(.prerelease==false)][0].assets[].browser_download_url | select(match("Linux_x86_64"))')
else
DOWNLOAD_URL=https://github.com/reproio/terraform-j2md/releases/download/${VERSION}/terraform-j2md_Linux_x86_64.tar.gz
fi
cd /tmp
curl -sfL ${DOWNLOAD_URL} | tar xzvf -
sudo install -D terraform-j2md ${RUNNER_TOOL_CACHE}/terraform-j2md/terraform-j2md
echo "${RUNNER_TOOL_CACHE}/terraform-j2md" >> $GITHUB_PATH

0 comments on commit b0a8400

Please sign in to comment.