Skip to content
This repository has been archived by the owner on Jan 21, 2025. It is now read-only.

Commit

Permalink
Merge pull request #19 from RossyWhite/action
Browse files Browse the repository at this point in the history
Add action.yml
  • Loading branch information
RossyWhite authored Jan 3, 2023
2 parents 47f5d3a + 4bdb8f7 commit 9587aa8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ jobs:
${{ runner.os }}-go-
- name: test
run: go test -race -cover ./...
- name: install test
run: ./install.sh

- name: prepare install test
run: |
echo 'image: {{ tfstate "docker_image.ubuntu.name" }}' > input.yaml
- name: run composite action
uses: ./
with:
input: input.yaml
output: output.yaml
tfstate: cmd/testdata/terraform.tfstate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: test output
run: |
diff output.yaml <(echo "image: ubuntu:latest")
24 changes: 24 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "tfsubst action"
author: "RossyWhite"
description: "Substitute variables with tfstate values"
inputs:
input:
description: 'File to run substitutions on'
required: true
output:
description: 'File to write result to'
required: true
tfstate:
description: 'Path to tfstate file'
required: true
runs:
using: "composite"
steps:
- name: "Install tfsubst"
run: |
curl -sfL https://raw.githubusercontent.com/RossyWhite/tfsubst/main/install.sh | sh
shell: bash
- name: "Run tfsubst"
run: |
tfsubst < ${{ inputs.input }} -s ${{ inputs.tfstate }} > ${{ inputs.output }}
shell: bash
2 changes: 0 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ fi

asset_id=$(curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
-sSf https://api.github.com/repos/"${owner}"/"${repo}"/releases/"${version}" \
| jq -r ".assets[] | select(.name == \"${file_name}\") | .id")

echo "[1/3] Downloading ${file_name}"
rm -f "${downloaded_file}"
curl -fsSL -H "Accept: application/octet-stream" \
-H "Authorization: Bearer ${GITHUB_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/"${owner}"/"${repo}"/releases/assets/"${asset_id}" \
-o "${downloaded_file}"
Expand Down

0 comments on commit 9587aa8

Please sign in to comment.