diff --git a/.github/workflows/metadata.yaml b/.github/workflows/metadata.yaml index a1fa158..7511576 100644 --- a/.github/workflows/metadata.yaml +++ b/.github/workflows/metadata.yaml @@ -59,7 +59,7 @@ on: value: ${{ jobs.meta.outputs.description }} topics: description: Project topics in JSON array - value: ${{ jobs.meta.outputs.topicsJson }} + value: ${{ jobs.meta.outputs.topics }} linuxName: description: Versioned filename that would be given to a library for this project on Linux value: ${{ jobs.meta.outputs.linuxName }} @@ -87,6 +87,9 @@ on: releasesUrl: description: Project releases API URL value: ${{ jobs.meta.outputs.releasesUrl }} + short_sha: + description: Short SHA of the commit being processed + value: ${{ jobs.meta.outputs.short_sha }} jobs: name: @@ -118,6 +121,7 @@ jobs: gitUrl: ${{ steps.url.outputs.gitUrl }} tagsUrl: ${{ steps.url.outputs.tagsUrl }} releasesUrl: ${{ steps.url.outputs.releasesUrl }} + short_sha: ${{ steps.api.outputs.short_sha }} steps: - name: Debug @@ -136,21 +140,23 @@ jobs: topics: ${{ toJSON(github.event.repository.topics) }} run: | # init + # shellcheck disable=SC2086 url="https://github.com/repos/${repo}" echo "url is ${url}" - echo "url=${url}" >> $GITHUB_OUTPUT + echo "url=${url}" >> "$GITHUB_OUTPUT" json="" # Define function updateValue() { [[ "$1" != "" ]] && _var="$1" || exit 1 [[ "$2" != "" ]] && _term="$2" || _term="$1" # if the value is an empty string or empty array - if [[ "${!_var}" =~ "^$|\[[[:space:]]*\]" ]] ; then - [[ "$json" == "" ]] && json=$(curl -s $url); - read "${_var}" <<< $(jq -r ".${_term}" <<< "$json") + if [[ "${!_var}" =~ ^$|\[[[:space:]]*\] ]] ; then + [[ "$json" == "" ]] && json=$(curl -s "$url"); + # shellcheck disable=SC2162,SC2229 + read "${_var}" <<< "$(jq -r ".${_term}" <<< "$json")" fi echo "${_var} is ${!_var}" - echo "${_var}=${!_var}" >> $GITHUB_OUTPUT + echo "${_var}=${!_var}" >> "$GITHUB_OUTPUT" } # Do work updateValue "defaultBranch" "default_branch" @@ -164,21 +170,22 @@ jobs: jsonTopics=$(jq -r ".topics" <<< "$json") echo "Retrieved topics are $jsonTopics" bothTopicArrays="$topics $jsonTopics" - topics=$(jq -s -c 'add | unique' <<< $bothTopicArrays) + topics=$(jq -s -c 'add | unique' <<< "$bothTopicArrays") echo "Final topics are $topics" - echo "topics=$topics" >> $GITHUB_OUTPUT + echo "topics=$topics" >> "$GITHUB_OUTPUT" + echo "short_sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" - name: Get Branch id: branch env: defaultBranch: ${{ steps.api.outputs.defaultBranch }} run: | - currentBranch=${GITHUB_REF#refs/heads/} - echo Branches current $currentBranch default $defaultBranch + currentBranch="${GITHUB_REF#refs/heads/}" + echo "Branches - current: $currentBranch - default: $defaultBranch" if [[ $currentBranch == refs/tags/* ]] ; then - currentBranch=$defaultBranch + currentBranch="$defaultBranch" fi - echo "currentBranch=${currentBranch}" >> $GITHUB_OUTPUT + echo "currentBranch=${currentBranch}" >> "$GITHUB_OUTPUT" - name: Links id: url @@ -195,8 +202,9 @@ jobs: if [ "$homepage" == "" ] ; then homepage="https://stirlinglabs.com" fi - echo "homepage=${homepage}" >> $GITHUB_OUTPUT - echo "gitUrl=${gitUrl}" >> $GITHUB_OUTPUT - echo "tagsUrl=${tagsUrl}" >> $GITHUB_OUTPUT - echo "releasesUrl=${releasesUrl}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2129 + echo "homepage=${homepage}" >> "$GITHUB_OUTPUT" + echo "gitUrl=${gitUrl}" >> "$GITHUB_OUTPUT" + echo "tagsUrl=${tagsUrl}" >> "$GITHUB_OUTPUT" + echo "releasesUrl=${releasesUrl}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/threshold.yaml b/.github/workflows/threshold.yaml index eb9fe9b..888d524 100644 --- a/.github/workflows/threshold.yaml +++ b/.github/workflows/threshold.yaml @@ -9,6 +9,12 @@ on: release: description: "This version is a release" value: ${{ jobs.check.outputs.release }} + sha: + description: "The SHA of the commit that was considered" + value: ${{ jobs.check.outputs.sha }} + short_sha: + description: "The short SHA of the commit that was considered" + value: ${{ jobs.check.outputs.short_sha }} jobs: check: @@ -18,6 +24,8 @@ jobs: outputs: continue: ${{ steps.collate_checks.outputs.process }} release: ${{ steps.released_check.outputs.release }} + sha: ${{ steps.collate_checks.outputs.sha }} + short_sha: ${{ steps.collate_checks.outputs.short_sha }} steps: - name: Dump GitHub context if: false @@ -33,7 +41,7 @@ jobs: contains(github.event.head_commit.message, '[force-ci]') || contains(github.event.head_commit.message, '[forceci]') run: | - echo "process=true" >> $GITHUB_OUTPUT + echo "process=true" >> "$GITHUB_OUTPUT" - name: Check if PR is a draft id: pr_draft_check @@ -42,7 +50,7 @@ jobs: env: process: ${{ !github.event.pull_request.draft }} run: | - echo "process=$process" >> $GITHUB_OUTPUT + echo "process=$process" >> "$GITHUB_OUTPUT" - name: Check if this is a Release id: released_check @@ -51,8 +59,8 @@ jobs: github.ref_type == 'tag' && startsWith(github.ref_name, 'v') run: | - echo "process=false" >> $GITHUB_OUTPUT - echo "release=true" >> $GITHUB_OUTPUT + echo "process=false" >> "$GITHUB_OUTPUT" + echo "release=true" >> "$GITHUB_OUTPUT" - name: Check if changes pushed id: push_new_check @@ -78,7 +86,7 @@ jobs: steps.push_new_check.outcome == 'skipped' run: | echo "All checks skipped, I don't have any meaningful input, so let's skip processing." - echo "process=false" >> $GITHUB_OUTPUT + echo "process=false" >> "$GITHUB_OUTPUT" - name: Collate Checks id: collate_checks @@ -115,8 +123,10 @@ jobs: [[ "$push_new_result" == "true" ]] && message="changes were pushed to the repo" [[ "$pr_draft_result" == "true" ]] && message="this is an active pull request" [[ "$force_ci_result" == "true" ]] && message="it was forced by the commit message" - echo "### Processing continuing since ${message}." >> $GITHUB_STEP_SUMMARY + echo "### Processing continuing since ${message}." >> "$GITHUB_STEP_SUMMARY" else - echo "### Continued processing does not appear to be necessary." >> $GITHUB_STEP_SUMMARY + echo "### Continued processing does not appear to be necessary." >> "$GITHUB_STEP_SUMMARY" fi - echo "process=$process" >> $GITHUB_OUTPUT + # shellcheck disable=SC2129 + echo "process=$process" >> "$GITHUB_OUTPUT" + echo "short_sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"