Skip to content

Commit

Permalink
Merge pull request #7 from mbround18/pipeline-output
Browse files Browse the repository at this point in the history
Pipeline output
  • Loading branch information
mbround18 authored Jul 7, 2022
2 parents ae34820 + 536ce8a commit f2821f8
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 50 deletions.
24 changes: 13 additions & 11 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.bin/
.idea/
tmp/
116 changes: 84 additions & 32 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,53 +20,105 @@ inputs:
description: "Auto command to run"
required: true
default: "shipit -v"
outputs:
version:
description: "Outputs the auto version."
value: ${{ steps.version.outputs.version }}
runs:
using: "composite"
steps:
- name: Setup Bins
shell: bash
shell: sh
run: |
export BIN_PATH="${GITHUB_ACTION_PATH}/.bin"
mkdir -p "${BIN_PATH}"
echo "::group::Setup Bin Folder"
. "${GITHUB_ACTION_PATH}/utils.sh"
setup
echo "${BIN_PATH}" >> $GITHUB_PATH
echo "::endgroup::"
- name: Setup JQ
shell: bash
shell: sh
if: inputs.autoVersion == 'latest'
run: |
echo "Setting jq path..."
export JQ_PATH="${GITHUB_ACTION_PATH}/.bin/jq"
echo "JQ_PATH=${JQ_PATH}"
echo "Downloading jq..."
wget -O "${JQ_PATH}" "https://github.com/stedolan/jq/releases/download/jq-${{inputs.jqVersion}}/jq-linux64"
echo "Making jq exectuabe..."
chmod +x "${JQ_PATH}"
echo "jq setup complete..."
echo "::group::Setup jq"
. "${GITHUB_ACTION_PATH}/utils.sh"
downloadBinary "stedolan" "jq" "jq" "jq-${{inputs.jqVersion}}" "jq-linux64"
echo "::endgroup::"
- name: Setup Auto
shell: bash
shell: sh
run: |
echo "Setting auto path..."
export AUTO_PATH="${GITHUB_ACTION_PATH}/.bin/auto"
echo "AUTO_PATH=${AUTO_PATH}"
echo "::group::Setup auto"
. "${GITHUB_ACTION_PATH}/utils.sh"
downloadAsset "intuit" "auto" "auto" "${{ inputs.autoVersion }}" "auto-linux.gz"
echo "::endgroup::"
export AUTO_URL=""
echo "Downloading auto..."
if [ "${{ inputs.autoVersion }}" = "latest" ]; then
echo "Fetching latest auto release..."
export LATEST_TAG="$(curl https://api.github.com/repos/intuit/auto/releases/latest -s | jq .name -r | xargs)"
AUTO_URL="https://github.com/intuit/auto/releases/download/${LATEST_TAG}/auto-linux.gz"
else
AUTO_URL="https://github.com/intuit/auto/releases/download/${{ inputs.autoVersion }}/auto-linux.gz"
fi
curl -vkL -o - "${AUTO_URL}" | gunzip > "${AUTO_PATH}"
echo "Making auto executable..."
chmod +x "${AUTO_PATH}"
echo "auto setup complete..."
- name: Setup Bins
- name: Run Auto
id: auto
shell: bash
env:
GH_TOKEN: "${{ inputs.token }}"
run: |
auto ${{ inputs.command }}
echo "::group::Run Auto"
set -o pipefail
OUTPUT_FILE="/tmp/auto.out"
auto ${{ inputs.command }} 2>&1 | tee "${OUTPUT_FILE}"
exit $?
echo "::endgroup::"
- name: Check & Setup PowerShell
shell: sh
run: |
if ! [ -x "$(command -v pwsh)" ]; then
echo "::group::Setup PowerShell"
. "${GITHUB_ACTION_PATH}/utils.sh"
downloadAsset "PowerShell" "PowerShell" "pwsh" "${{ inputs.autoVersion }}" "powershell-{VERSION_NO_PREFIX}-linux-x64.tar.gz"
echo "::endgroup::"
fi
- name: Parse Version
shell: pwsh
id: version
run: |
Write-Output "::group::Parse Version"
$File = "/tmp/auto.out"
$Version = ""
function parse {
param (
$File,
$Pattern,
$SubPattern
)
$FileContent = (Select-String $File -Context 2 -Pattern $Pattern)
return $FileContent | Out-String | Select-String -Pattern $SubPattern
}
$Options = @( @{
Pattern = "Calling canary hook"
SubPattern = "HEAD:"
Matcher = "got commit sha from head: (.+)"
Prefix = "sha-"
},@{
Pattern = "Created GitHub release"
SubPattern = "tag:"
Matcher = "Creating release on GitHub for tag: (v.+)"
})
$Options | ForEach-Object {
$Out = parse -File $File -Pattern $_.Pattern -SubPattern $_.SubPattern
if ($Out -match $_.Matcher) {
$Revision = ($Matches[1] | Out-String)
if ($_.Prefix) {
$Version = $_.Prefix + $Revision
} else {
$Version = $Revision
}
}
}
Write-Output "Version=$Version"
Write-Output "::set-output name=version::$Version"
Write-Output "::endgroup::"
4 changes: 1 addition & 3 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": [
"config:base"
]
"extends": ["config:base"]
}
76 changes: 76 additions & 0 deletions utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env sh

setup() {
export BIN_PATH="${GITHUB_ACTION_PATH}/.bin"
mkdir -p "${BIN_PATH}"
}

downloadBinary() {
OWNER="$1"
REPOSITORY="$2"
NAME="$3"
VERSION="$4"
ASSET="$5"
echo "::group::Download ${NAME}"
echo "Setting ${NAME} path..."
BIN_PATH="${GITHUB_ACTION_PATH}/.bin/${NAME}"
echo "BIN_PATH=${BIN_PATH}"
echo "Downloading ${NAME}..."
wget -O "${BIN_PATH}" "https://github.com/${OWNER}/${REPOSITORY}/releases/download/${VERSION}/${ASSET}"
echo "Making ${NAME} executable..."
chmod +x "${BIN_PATH}"
echo "${NAME} setup complete..."
echo "::endgroup::"
}

getLatestVersion() {
OWNER="$1"
REPOSITORY="$2"

if ! [ -x "$(command -v jq)" ]; then
echo "Error: Failed to find executable 'jq'."
fi

curl "https://api.github.com/repos/${OWNER}/${REPOSITORY}/releases/latest" -s | jq .tag_name -r | xargs
}

downloadAsset() {
OWNER="$1"
REPOSITORY="$2"
NAME="$3"
VERSION="$4"
ASSET="$5"
echo "::group::Download ${NAME}"

echo "Setting ${NAME} path..."
BIN_PATH="${GITHUB_ACTION_PATH}/.bin"
BINARY_PATH="${BIN_PATH}/${NAME}"
DOWNLOAD_URL=""
echo "Downloading ${NAME}..."
if [ "${VERSION}" = "latest" ]; then
echo "Fetching latest ${NAME} release..."
LATEST_TAG="$(getLatestVersion "${OWNER}" "${REPOSITORY}")"
VERSION=${LATEST_TAG}
DOWNLOAD_URL="https://github.com/${OWNER}/${REPOSITORY}/releases/download/${LATEST_TAG}"
else
DOWNLOAD_URL="https://github.com/${OWNER}/${REPOSITORY}/releases/download/${VERSION}"
fi

VERSION_NO_PREFIX="$(echo "${VERSION}" | tr -d "v")"
ASSET_WITH_VERSION="$(echo "${ASSET}" | sed "s/{VERSION}/${VERSION}/" | sed "s/{VERSION_NO_PREFIX}/${VERSION_NO_PREFIX}/")"
DOWNLOAD_URL="${DOWNLOAD_URL}/${ASSET_WITH_VERSION}"

case "${ASSET_WITH_VERSION}" in
*.tar.gz)
wget -c "${DOWNLOAD_URL}" -O - | tar -xz -C "${BIN_PATH}"
;;
*.gz)
curl -vkL -o - "${DOWNLOAD_URL}" | gunzip > "${BINARY_PATH}"
;;
esac

echo "Making ${NAME} executable..."
chmod +x "${BINARY_PATH}"
echo "${NAME} setup complete..."
echo "::endgroup::"
}

0 comments on commit f2821f8

Please sign in to comment.