Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions setup-certificate-1p/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,47 @@ inputs:
runs:
using: composite
steps:
# 1password/install-cli-action calls https://app-updates.agilebits.com/latest to resolve "latest"
# to a concrete version, and that endpoint has degraded before (see
# https://github.com/1Password/install-cli-action/issues/42). Resolve the version ourselves so we
# can fall back to the S3-backed changelog page on releases.1password.com when the primary
# resolver is down, and pass a concrete version to the install action.
- name: Resolve 1Password CLI version
id: opVersion
shell: bash
run: |
set -uo pipefail
version=""

if resp=$(curl -sSf -m 10 https://app-updates.agilebits.com/latest 2>/dev/null); then
version=$(echo "$resp" | jq -r '.CLI2.release.version // empty')
fi

if [ -z "$version" ]; then
echo "::warning title=1Password /latest endpoint degraded::Falling back to changelog scrape at releases.1password.com. See https://github.com/1Password/install-cli-action/issues/42"
# Anchor on the per-release id=1password-cli-X.Y.Z headings on the changelog page.
# A looser number-shaped regex over the whole page also matches SVG path coordinates
# (e.g. 2.85714286.0), which would then be handed to the install action and 404.
# sort -V is GNU-only; the composite action runs on macOS (BSD sort) too,
# so compare numerically across the three dotted fields with POSIX sort.
version=$(curl -sSf -m 10 https://releases.1password.com/developers/cli/ 2>/dev/null \
| grep -oE '1password-cli-[0-9]+\.[0-9]+\.[0-9]+' \
| grep -oE '[0-9]+\.[0-9]+\.[0-9]+' \
| sort -u -t. -k1,1n -k2,2n -k3,3n | tail -1)
fi

if [ -z "$version" ]; then
echo "::error::Unable to determine 1Password CLI version from any source"
exit 1
fi

echo "Resolved op CLI version: $version"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Install 1Password CLI
uses: 1password/install-cli-action@9a0c9dd934086b7ab1d90115d455bda1c53c2bdb
with:
version: ${{ steps.opVersion.outputs.version }}
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ inputs.OP_SERVICE_ACCOUNT_TOKEN }}

Expand Down
Loading