diff --git a/.github/shellcheck-actions.sh b/.github/shellcheck-actions.sh
index d44381e..1355994 100644
--- a/.github/shellcheck-actions.sh
+++ b/.github/shellcheck-actions.sh
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
info() { echo -e "\e[92m[+] $@\e[0m"; }
-error() { echo >&2 -e "\e[31m[!] $@\e[0m"; exit 1; }
-warn() { echo -e "\e[33m[-] $@\e[0m"; }
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
export SHELLCHECK_OPTS=(
@@ -14,6 +12,6 @@ export SHELLCHECK_OPTS=(
)
for f in "$DIR"/../**/*.yaml; do
- echo $f
+ info "Linting scripts in $f"
yq '.runs.steps[].run' "$f" | grep -v -P "^null$" | shellcheck "${SHELLCHECK_OPTS[@]}" -
done
diff --git a/call-for-testing/action.yaml b/call-for-testing/action.yaml
index 55f09cd..bd6d0d5 100644
--- a/call-for-testing/action.yaml
+++ b/call-for-testing/action.yaml
@@ -69,8 +69,8 @@ runs:
fi
done
fi
- if [[ ! -n "${yaml-path}" ]]; then
- echo "No snapcraft.yaml found" >2
+ if [[ -z "${yaml_path}" ]]; then
+ echo "No snapcraft.yaml found"
exit 1
fi
echo "yaml-path=${yaml_path}" >> "$GITHUB_OUTPUT"
@@ -94,10 +94,10 @@ runs:
echo "Found build manifests - populating template with revisions from the manifests"
# Iterate over the manifest files and write the table rows for each architecture
- for file in $(ls manifest-*.yaml); do
+ for file in manifest-*.yaml; do
# Parse the arch and the revision
- arch="$(cat "${file}" | yq -r '.architecture')"
- rev="$(cat "${file}" | yq -r '.revision')"
+ arch="$(yq -r '.architecture' "${file}")"
+ rev="$(yq -r '.revision' "${file}")"
# Write the table row and add the revision to the list we're tracking
table="${table}
${arch} | ${rev} |
"
revisions+=("$rev")
@@ -106,6 +106,7 @@ runs:
echo "No build manifests found - populating template with information from the store"
# Otherwise, get the latest revision for each architecture in the release channel
+ # shellcheck disable=SC1083
for arch in ${{ inputs.architectures }}; do
rev="$(snapcraft list-revisions "${snap_name}" --arch "$arch" | grep "latest/${{ inputs.channel }}*" | head -n1 | cut -d' ' -f1)"
revisions+=("$rev")
@@ -120,7 +121,7 @@ runs:
# Get a comma separated list of revisions
printf -v joined '%s,' "${revisions[@]}"
- version="$(cat "$snapcraft_yaml" | yq -r '.version')"
+ version="$(yq -r '.version' "$snapcraft_yaml")"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "revisions=${joined%,}" >> "$GITHUB_OUTPUT"
echo "table=${table}" >> "$GITHUB_OUTPUT"
diff --git a/get-architectures/action.yaml b/get-architectures/action.yaml
index 1c93851..f02ce00 100644
--- a/get-architectures/action.yaml
+++ b/get-architectures/action.yaml
@@ -44,8 +44,8 @@ runs:
fi
done
fi
- if [[ ! -n "${yaml-path}" ]]; then
- echo "No snapcraft.yaml found" >2
+ if [[ -z "${yaml_path}" ]]; then
+ echo "No snapcraft.yaml found"
exit 1
fi
echo "yaml-path=${yaml_path}" >> "$GITHUB_OUTPUT"
@@ -58,15 +58,15 @@ runs:
yaml_path: ${{ steps.yaml-path.outputs.yaml-path }}
run: |
# Get the list as a json array. E.g. ["amd64", "arm64"]
- architectures_list="$(cat "$yaml_path" | yq -r -I=0 -o=json '[.architectures[]]')"
+ architectures_list="$(yq -r -I=0 -o=json '[.architectures[]]' | "$yaml_path")"
# Get the list as a space-separated string. E.g. "amd64" "arm64"
- architectures="$(cat "$yaml_path" | yq -r -I=0 -o=csv '[.architectures[]]' | tr ',' ' ')"
+ architectures="$(yq -r -I=0 -o=csv '[.architectures[]]' "$yaml_path" | tr ',' ' ')"
# Handle the case where architectures is a list of objects
if echo "$architectures" | grep -q "build-on"; then
- architectures_list="$(cat "$yaml_path" | yq -r -I=0 -o=json '[.architectures[]."build-on"]')"
- architectures="$(cat "$yaml_path" | yq -r -I=0 -o=csv '[.architectures[]."build-on"]' | tr ',' ' ')"
+ architectures_list="$(yq -r -I=0 -o=json '[.architectures[]."build-on"]' "$yaml_path")"
+ architectures="$(yq -r -I=0 -o=csv '[.architectures[]."build-on"]' "$yaml_path" | tr ',' ' ')"
fi
echo "architectures_list=$architectures_list" >> "$GITHUB_OUTPUT"
diff --git a/get-screenshots/action.yaml b/get-screenshots/action.yaml
index 35434c5..025dc9f 100644
--- a/get-screenshots/action.yaml
+++ b/get-screenshots/action.yaml
@@ -74,8 +74,8 @@ runs:
fi
done
fi
- if [[ ! -n "${yaml-path}" ]]; then
- echo "No snapcraft.yaml found" >2
+ if [[ -z "${yaml_path}" ]]; then
+ echo "No snapcraft.yaml found"
exit 1
fi
echo "yaml-path=${yaml_path}" >> "$GITHUB_OUTPUT"
@@ -90,7 +90,7 @@ runs:
# If we got a manifest file then parse the revision from it
if ls manifest-amd64.yaml &>/dev/null; then
- rev="$(cat manifest-amd64.yaml | yq -r '.revision')"
+ rev="$(yq -r '.revision' manifest-amd64.yaml)"
echo "Installing snap revision '${rev}' from build manifest"
ghvmctl install-snap "${snap_name}" --revision "${rev}"
else
@@ -129,7 +129,7 @@ runs:
run: |
file_prefix="$(date +%Y%m%d)-${snap_name}-${{ inputs.issue-number }}"
- pushd ci-screenshots
+ pushd ci-screenshots || exit 1
mv "$HOME/ghvmctl-screenshots/screenshot-screen.png" "${file_prefix}-screen.png"
mv "$HOME/ghvmctl-screenshots/screenshot-window.png" "${file_prefix}-window.png"
diff --git a/promote-to-stable/action.yaml b/promote-to-stable/action.yaml
index 9201f26..d1aad77 100644
--- a/promote-to-stable/action.yaml
+++ b/promote-to-stable/action.yaml
@@ -55,8 +55,8 @@ runs:
fi
done
fi
- if [[ ! -n "${yaml-path}" ]]; then
- echo "No snapcraft.yaml found" >2
+ if [[ -z "${yaml_path}" ]]; then
+ echo "No snapcraft.yaml found"
exit 1
fi
echo "yaml-path=${yaml_path}" >> "$GITHUB_OUTPUT"
@@ -71,6 +71,7 @@ runs:
run: |
echo "The command was '${{ steps.command.outputs.command-name }}' with arguments '${{ steps.command.outputs.command-arguments }}'"
+ # shellcheck disable=SC1083,SC2206
arguments=(${{ steps.command.outputs.command-arguments }})
revision=${arguments[0]}
channel=${arguments[1]}
@@ -93,20 +94,20 @@ runs:
fi
# Iterate over each specified revision and release
- revs=$(echo $revision | tr "," "\n")
+ revs=$(echo "$revision" | tr "," "\n")
released_revs=()
for r in $revs; do
- snapcraft release $snap_name "$r" "$channel"
+ snapcraft release "$snap_name" "$r" "$channel"
released_revs+=("$r")
done
# Get a comma separated list of released revisions
printf -v joined '%s,' "${released_revs[@]}"
- echo "revisions=${joined%,}" >> $GITHUB_OUTPUT
- echo "channel=$channel" >> $GITHUB_OUTPUT
- echo "done=$done" >> $GITHUB_OUTPUT
+ echo "revisions=${joined%,}" >> "$GITHUB_OUTPUT"
+ echo "channel=$channel" >> "$GITHUB_OUTPUT"
+ echo "done=$done" >> "$GITHUB_OUTPUT"
- name: Comment on call for testing issue
uses: actions/github-script@v7
diff --git a/release-to-candidate/action.yaml b/release-to-candidate/action.yaml
index 4d55d99..5501ecd 100644
--- a/release-to-candidate/action.yaml
+++ b/release-to-candidate/action.yaml
@@ -66,8 +66,8 @@ runs:
fi
done
fi
- if [[ ! -n "${yaml_path}" ]]; then
- echo "No snapcraft.yaml found" >2
+ if [[ -z "${yaml_path}" ]]; then
+ echo "No snapcraft.yaml found"
exit 1
fi
echo "yaml-path=${yaml_path}" >> "$GITHUB_OUTPUT"
diff --git a/sync-version/action.yaml b/sync-version/action.yaml
index 9115611..9e523fc 100644
--- a/sync-version/action.yaml
+++ b/sync-version/action.yaml
@@ -44,8 +44,8 @@ runs:
fi
done
fi
- if [[ ! -n "${yaml-path}" ]]; then
- echo "No snapcraft.yaml found" >2
+ if [[ -z "${yaml_path}" ]]; then
+ echo "No snapcraft.yaml found"
exit 1
fi
echo "yaml-path=${yaml_path}" >> "$GITHUB_OUTPUT"
@@ -55,14 +55,15 @@ runs:
- name: Run update script
shell: bash
run: |
+ # shellcheck disable=SC2288,SC2086,SC1083
${{ inputs.update-script }}
- name: Check for modified files
shell: bash
id: git-check
run: |
- MODIFIED=$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")
- echo "modified=$MODIFIED" >> $GITHUB_OUTPUT
+ MODIFIED=$([ -z "$(git status --porcelain)" ] && echo "false" || echo "true")
+ echo "modified=$MODIFIED" >> "$GITHUB_OUTPUT"
- name: Commit changes
if: steps.git-check.outputs.modified == 'true'
diff --git a/test-snap-build/action.yaml b/test-snap-build/action.yaml
index f4941d2..2abacfd 100644
--- a/test-snap-build/action.yaml
+++ b/test-snap-build/action.yaml
@@ -40,8 +40,8 @@ runs:
fi
done
fi
- if [[ ! -n "${yaml_path}" ]]; then
- echo "No snapcraft.yaml found" >2
+ if [[ -z "${yaml_path}" ]]; then
+ echo "No snapcraft.yaml found"
exit 1
fi
echo "yaml-path=${yaml_path}" >> "$GITHUB_OUTPUT"
@@ -94,4 +94,4 @@ runs:
if: ${{ inputs.install == 'true' }}
shell: bash
run: |
- sudo snap install --classic --dangerous ${{ steps.build.outputs.snap }}
+ sudo snap install --classic --dangerous "${{ steps.build.outputs.snap }}"