CI: the VoelinProtocol deploy key lives for one trusted fetch step #2

Merged
faumaray merged 8 commits from phase5/ci-deploy-key-hardening into main 2026-10-28 01:27:14 +00:00
3 changed files with 277 additions and 143 deletions
Showing only changes of commit cfde421af4 - Show all commits

No files matched your search

+29 -131
View File
@@ -1,135 +1,21 @@
name: Linux checks
description: Shared Linux validation for Gitea CI and release packaging.
inputs:
protocol-deploy-key:
description: >
Private half of the read-only deploy key registered on the private
Voelin/VoelinProtocol repository (the repository secret
VOELIN_PROTOCOL_DEPLOY_KEY, passed in by the workflow: secrets are not
visible inside a composite action). The action fails when it is empty.
required: true
description: >
Linux validation for Gitea CI: formatting, Clippy, the build, the tests, the
dependency policy, the third-party notices and the release tooling tests. It
runs after the job has fetched every dependency (the steps before it in
.gitea/workflows/ci.yml: system packages, the Rust toolchain and `cargo fetch`
with the read-only deploy key for the private VoelinProtocol repository) and
has deleted the key (docs/ci.md, "VoelinProtocol access"). This action has no
input and no secret, and every cargo command in it is --offline (or has
CARGO_NET_OFFLINE set where a script or a plugin starts cargo): it needs no key
and cannot use one, so the build scripts, procedural macros and tests it runs
hold none.
runs:
using: composite
steps:
# The workspace depends on the private VoelinProtocol repository over SSH
# (docs/ci.md, "VoelinProtocol access"). First, so that a missing key fails
# in seconds and before anything runs cargo.
- name: Install the VoelinProtocol deploy key
# The key reaches this step through the environment only: never in the
# script text, never echoed, no `set -x`.
env:
PROTOCOL_DEPLOY_KEY: ${{ inputs.protocol-deploy-key }}
run: |
set -euo pipefail
umask 077
if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then
echo "::error::The VoelinProtocol deploy key is empty. Set the repository secret VOELIN_PROTOCOL_DEPLOY_KEY to the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access). Pull requests from forks get no secrets." >&2
exit 1
fi
for tool in ssh ssh-keygen; do
command -v "$tool" > /dev/null || {
echo "::error::The job image needs the OpenSSH client: $tool is missing." >&2
exit 1
}
done
ssh_dir="$HOME/.ssh"
key_file="$ssh_dir/voelin_protocol"
mkdir -p "$ssh_dir"
chmod 700 "$ssh_dir"
# Whatever the secret store did to the line ends and the final newline,
# OpenSSH needs LF lines, the BEGIN line first and a newline at the end.
printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' > "$key_file"
unset PROTOCOL_DEPLOY_KEY
chmod 600 "$key_file"
if ! public=$(ssh-keygen -y -f "$key_file" < /dev/null); then
rm -f "$key_file"
echo "::error::VOELIN_PROTOCOL_DEPLOY_KEY is not an unencrypted OpenSSH or PEM private key." >&2
exit 1
fi
# The fingerprint of the public half, to compare with the deploy key in
# the VoelinProtocol settings.
printf 'Deploy key installed: %s\n' "$(ssh-keygen -lf - <<< "$public")"
# The reviewed host key from the repository, never one fetched now.
known_hosts="$ssh_dir/known_hosts"
touch "$known_hosts"
chmod 600 "$known_hosts"
[[ -s "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts" ]] || {
echo "::error::.gitea/known_hosts is missing from the checkout." >&2
exit 1
}
while IFS= read -r line; do
case "$line" in '' | '#'*) continue ;; esac
grep -qxF -- "$line" "$known_hosts" || printf '%s\n' "$line" >> "$known_hosts"
done < "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts"
# Use this key, and only this one, for the Gitea server; fail rather than
# ask when its host key is unknown or changed. The block goes first: ssh
# takes the first value it finds for each option.
config="$ssh_dir/config"
marker="# VoelinProtocol deploy key (.gitea/actions/checks)"
touch "$config"
if ! grep -qxF -- "$marker" "$config"; then
{
cat << EOF
$marker
Host git.faumaray.com
User gitea
IdentityFile $key_file
IdentitiesOnly yes
UserKnownHostsFile $known_hosts
StrictHostKeyChecking yes
BatchMode yes
ConnectTimeout 30
EOF
cat "$config"
} > "$config.new"
mv "$config.new" "$config"
fi
chmod 600 "$config"
# Cargo's built-in git client (libgit2) cannot use IdentityFile; the
# system git runs ssh, which reads the config above. `-F` names it
# outright: ssh looks for ~/.ssh in the passwd entry's home directory, not
# in $HOME, and a job image may set the two apart.
{
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true"
echo "GIT_SSH_COMMAND=ssh -F '$config'"
} >> "$GITHUB_ENV"
shell: bash
- uses: ./.github/actions/system-deps
- name: Check read access to VoelinProtocol
# The first thing cargo does, with the same git and ssh configuration, so
# that a wrong key or a changed host key fails here with a clear message
# and not minutes later inside a cargo command.
run: |
set -euo pipefail
if ! GIT_TERMINAL_PROMPT=0 timeout 120 git ls-remote --exit-code \
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git HEAD > /dev/null; then
echo "::error::git cannot read Voelin/VoelinProtocol over SSH with the deploy key. 'Permission denied (publickey)' above: the key is not registered on that repository (or is not the one in VOELIN_PROTOCOL_DEPLOY_KEY). 'Host key verification failed': .gitea/known_hosts no longer matches the server (docs/ci.md, VoelinProtocol access)." >&2
exit 1
fi
echo "Voelin/VoelinProtocol is readable with the deploy key."
shell: bash
- name: Install pinned Rust toolchain
run: |
set -euo pipefail
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
export PATH="$CARGO_HOME/bin:$PATH"
if ! command -v rustup >/dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile minimal --default-toolchain none
fi
if [[ -f "$CARGO_HOME/env" ]]; then
# shellcheck source=/dev/null
source "$CARGO_HOME/env"
fi
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
rustup toolchain install
shell: bash
- name: rustfmt (own crates)
env:
CARGO_NET_OFFLINE: "true"
run: |
set -euo pipefail
packages=$(scripts/own-crates.sh)
@@ -137,33 +23,45 @@ runs:
cargo fmt "${packages[@]}" --check
shell: bash
- name: clippy (own crates, deny warnings)
env:
CARGO_NET_OFFLINE: "true"
run: |
set -euo pipefail
packages=$(scripts/own-crates.sh)
read -r -a packages <<< "$packages"
cargo clippy "${packages[@]}" --all-targets --no-deps --locked -- -D warnings
cargo clippy "${packages[@]}" --all-targets --no-deps --locked --offline -- -D warnings
shell: bash
- name: clippy (workspace, report warnings)
run: cargo clippy --workspace --all-targets --locked
run: cargo clippy --workspace --all-targets --locked --offline
shell: bash
- name: Build
run: cargo build --workspace --all-targets --locked
run: cargo build --workspace --all-targets --locked --offline
shell: bash
- name: Test (X11 enabled)
run: |
# DISPLAY is assigned by xvfb-run, then expanded by the inner shell.
# shellcheck disable=SC2016
xvfb-run -a bash -c 'VOELIN_X11_TEST_DISPLAY="$DISPLAY" cargo test --workspace --locked'
xvfb-run -a bash -c 'VOELIN_X11_TEST_DISPLAY="$DISPLAY" cargo test --workspace --locked --offline'
shell: bash
- name: Install cargo-deny and cargo-about
# The only cargo commands here that go online: they download two tools from
# crates.io and build them. They read no manifest of this workspace and
# nothing in the job gives them a key.
run: |
cargo install cargo-deny --locked --version 0.20.2
cargo install cargo-about --locked --version 0.9.2 --features cli
shell: bash
- name: Dependency policy
# cargo-deny's own --offline would also stop it from fetching the RustSec
# advisory database, which the check needs (from github.com, no key).
# CARGO_NET_OFFLINE keeps only the `cargo metadata` it runs offline.
env:
CARGO_NET_OFFLINE: "true"
run: cargo deny --locked --workspace check
shell: bash
- name: Third-party notices
env:
CARGO_NET_OFFLINE: "true"
run: scripts/notices.sh --check
shell: bash
- name: Release tooling regressions
+4 -3
View File
@@ -4,7 +4,8 @@
#
# Committed, never fetched while a job runs, so a CI or release build trusts the
# key reviewed here and not whatever answers on the network at that moment.
# Read by .gitea/actions/checks (appended to ~/.ssh/known_hosts) and COPYed by
# docker/*.Dockerfile and crates/voelin-gateway/Dockerfile. How to re-check it
# and how to rotate it: docs/ci.md, "VoelinProtocol access".
# Read in place by ssh (-o UserKnownHostsFile, in the command line that the fetch
# step of .gitea/workflows/ci.yml gives git: nothing is appended to ~/.ssh) and
# COPYed by docker/*.Dockerfile and crates/voelin-gateway/Dockerfile. How to
# re-check it and how to rotate it: docs/ci.md, "VoelinProtocol access".
git.faumaray.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzZEz9JLrzk6oLiloSbueAN28vYL58Y/dTHBgRuBMMib9IJ1aDJShhr3kwC9sfOT0AzK0uwcMAqCAIkwJwttde8dIg0Mee0cmB/1JkoqFF4X3MUGD1r3nk8SSZNhIiPqo16hDF9Hf3FkovztIlBVntkyP9Iy9hYfP818Tiq3yRXROGdHjR7IfY4jR2QGfGrd/RtvPGExVqusxidy141240A8aRAwMFUqFdEvmXWjizrtCUqcrL/k1GEh0yJzbCdNOVUI6OuWd8tPluSBvmmeoNpKnCSl4Mkg36HObbOyrsme0asZqjcj0od65WYWApMPN0pUqhNu2CP83Nfor2VFwkdPRwe7cAZ0OD/8wyT6Hz5q1wWgf82y4tYDoDRYsd8JU86eebkJ07T5nCrEeC4Sj+qT4S5xv/kECAhxyP4QGnunORnY2fYsdNGzpPvbMN7gHe9UcIcQdOIgV3wrR1qpMVNcd8AEC2A3TRv/jzMCHSjmGGpgiy1Db2CZAjp5+PcjNmjvoPNN0NiA9X4rIVSeTfflWnDRmeNRJeZa73StjpU17EcAf97COUQPGWJQDgpJqINSpYU50fuaLBfzKnIRuiHjKQmyKe/zgRSmulnYFYM3AJfn8Ykg2VvkUQGvCt1+fqYiUa1iVFuwPP3ZigYF1mOZRpPnos5kaNmlB01q2sZw==
+244 -9
View File
@@ -1,7 +1,22 @@
name: CI
# Linux checks for Gitea act_runner; runner setup and scope: docs/ci.md.
# Off for pushes and pull requests: run by hand only.
# Runs on pushes to main and on pull requests (not when only docs or Markdown
# files change, apart from THIRD_PARTY_NOTICES.md), and by hand.
#
# The workspace depends on the private VoelinProtocol repository over SSH, so
# the job needs the read-only deploy key (the repository secret
# VOELIN_PROTOCOL_DEPLOY_KEY). The key exists for one step only: "Fetch the
# dependencies" runs `cargo fetch` with it, before any build script, procedural
# macro or test of the repository has run, and deletes it again. Everything after
# that (the composite action .gitea/actions/checks) runs `--offline` in a job that
# holds no key. docs/ci.md, "VoelinProtocol access", has the whole story; the
# order of the steps is part of it:
#
# 1. check that this job may hold the key (the runner, the pull request's head)
# 2. system packages and the Rust toolchain (no key yet)
# 3. install the key into a directory of its own, 4. fetch with it and delete it
# 5. delete it again whatever happened, 6. the checks, offline
on:
push:
branches: ["main"]
@@ -21,9 +36,8 @@ on:
env:
CARGO_TERM_COLOR: always
# Cargo fetches the private VoelinProtocol dependency with the system git and
# ssh (docs/ci.md, "VoelinProtocol access"). The checks action exports this
# too; set here as well, it does not depend on the runner handing a composite
# action's GITHUB_ENV on to the later steps.
# ssh, whose command line the fetch step sets (docs/ci.md, "VoelinProtocol
# access"); Cargo's own git client could not use that key file.
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
jobs:
@@ -31,14 +45,235 @@ jobs:
name: Linux checks
runs-on: ubuntu-24.04
timeout-minutes: 180
env:
# 'yes' unless this run is a pull request whose head branch lives in
# another repository. For a pull request Gitea's event payload has
# github.event.pull_request.head.repo.full_name, the repository that holds
# the branch to be merged: this repository (equal to github.repository)
# for a branch pushed here, the fork's own name for a fork. Any other
# event (push, workflow_dispatch) has no pull request and the first
# operand is true at once. An absent or unequal name reads 'no', and the
# check below treats everything but 'yes' as no. The check asks the same
# question again in its script, from the head repository's name itself.
VOELIN_PR_HEAD_HERE: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'yes' || 'no' }}
defaults:
run:
shell: bash
steps:
- uses: https://github.com/actions/checkout@v4
# A runner prints the `env:` of a step in the job log when the step starts,
# and the runner "gitea-runner-docker" v0.6.1 printed a multi-line secret
# there in clear (the deploy keys of all four repositories, 2026-10-27; they
# were rotated the next day). Both runners carry the same labels, so
# `runs-on` cannot keep the job off it. What the workflow can do is not to
# start the step that declares the secret on such a runner, and not to give
# the secret to a fork's pull request: this step decides, before any step
# names the secret, and writes the one positive flag that the key step asks
# for. Without the flag the job stops here: the key is not optional (nothing
# builds without voelin-identity), and a green job that checked nothing
# would be worse than a red one that says why.
- name: Check that this job may hold the VoelinProtocol deploy key
env:
# The oldest runner version known to mask a multi-line secret in the
# log. Lower it only after a canary secret has been shown masked on
# that runner (docs/ci.md, "VoelinProtocol access"). release.yml has
# the same line.
MIN_MASKING_RUNNER_VERSION: 3.1.0
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
run: |
set -euo pipefail
version="${GITEA_ACTIONS_RUNNER_VERSION:-}"
name="${RUNNER_NAME:-an unnamed runner}"
problems=()
masks=no
if [[ "$version" =~ ^v?([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
oldest="$(printf '%s\n%s\n' "$MIN_MASKING_RUNNER_VERSION" "${BASH_REMATCH[1]}" | sort -V | head -n 1)"
if [[ "$oldest" == "$MIN_MASKING_RUNNER_VERSION" ]]; then
masks=yes
echo "Runner $name reports version $version, which masks secrets in the log (at least $MIN_MASKING_RUNNER_VERSION)."
fi
fi
if [[ "$masks" != yes ]]; then
problems+=("the runner ($name) reports version '${version:-none}', and only a runner of version $MIN_MASKING_RUNNER_VERSION or newer is known to keep the deploy key out of the job log (gitea-runner-docker v0.6.1 printed it in clear). Run the job again: it may be given another runner")
fi
# The pull request's head. The job-level expression has answered in
# VOELIN_PR_HEAD_HERE; the answer is asked for again here, from the
# head repository's name and the repository's, so that a mistake in
# one of the two places does not hand the key to a fork's code. A pull
# request (any event whose name starts with pull_request, or any event
# that carries a head repository) passes only with a head repository
# that is named and is this repository.
head_here=yes
[[ "${VOELIN_PR_HEAD_HERE:-}" == yes ]] || head_here=no
case "${GITHUB_EVENT_NAME:-}" in
pull_request*) pull_request=yes ;;
*) pull_request=no ;;
esac
[[ -z "${PR_HEAD_REPO:-}" ]] || pull_request=yes
if [[ "$pull_request" == yes ]]; then
if [[ -z "${PR_HEAD_REPO:-}" || "$PR_HEAD_REPO" != "${GITHUB_REPOSITORY:-}" ]]; then
head_here=no
fi
fi
if [[ "$head_here" == yes ]]; then
if [[ "$pull_request" == yes ]]; then
echo "Event ${GITHUB_EVENT_NAME:-unknown}: the pull request's head is in $PR_HEAD_REPO, which is this repository, not a fork."
else
echo "Event ${GITHUB_EVENT_NAME:-unknown}: no pull request, the code is this repository's own."
fi
else
problems+=("the pull request's head repository is '${PR_HEAD_REPO:-unknown}', and this repository is ${GITHUB_REPOSITORY:-unknown}, so it is a fork's pull request (or the event did not say where the head is), and the key is not given to a fork's code. Push the branch to ${GITHUB_REPOSITORY:-this repository} to have it checked")
fi
if ((${#problems[@]})); then
for problem in "${problems[@]}"; do
echo "::error::The VoelinProtocol deploy key is not given to this job: $problem." >&2
done
echo "::error::The job stops here: the workspace cannot be built without the private VoelinProtocol repository (docs/ci.md, VoelinProtocol access)." >&2
exit 1
fi
echo "VOELIN_KEY_ALLOWED=yes" >> "$GITHUB_ENV"
# Native libraries and tools (apt), the same action as GitHub CI. The job
# image has git and the OpenSSH client; the key step checks for ssh.
- uses: ./.github/actions/system-deps
- name: Install pinned Rust toolchain
run: |
set -euo pipefail
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
export PATH="$CARGO_HOME/bin:$PATH"
if ! command -v rustup >/dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --profile minimal --default-toolchain none
fi
if [[ -f "$CARGO_HOME/env" ]]; then
# shellcheck source=/dev/null
source "$CARGO_HOME/env"
fi
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
rustup toolchain install
# The key, as late as it can be: after the packages and the toolchain have
# been installed, right before the one step that uses it.
- name: Install the VoelinProtocol deploy key
# Both lines below ask for the positive flag of the check above. On a
# runner that is not known to mask the secret (or whose expression context
# does not hold what an earlier step wrote to GITHUB_ENV) the flag reads
# empty: the step is not started, so it prints no header, and the
# expression is empty as well, in case a runner prints a header anyway.
# The key reaches the step through the environment only: never in the
# script text, never echoed, no `set -x`. A pull request from a fork gets
# no secrets from Gitea and fails the check above before it gets here.
if: env.VOELIN_KEY_ALLOWED == 'yes'
env:
PROTOCOL_DEPLOY_KEY: ${{ env.VOELIN_KEY_ALLOWED == 'yes' && secrets.VOELIN_PROTOCOL_DEPLOY_KEY || '' }}
run: |
set -euo pipefail
umask 077
if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then
echo "::error::The VoelinProtocol deploy key is empty. Set the repository secret VOELIN_PROTOCOL_DEPLOY_KEY to the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access)." >&2
exit 1
fi
for tool in ssh ssh-keygen; do
command -v "$tool" > /dev/null || {
echo "::error::The job image needs the OpenSSH client: $tool is missing." >&2
exit 1
}
done
[[ -s "$GITHUB_WORKSPACE/.gitea/known_hosts" ]] || {
echo "::error::.gitea/known_hosts is missing from the checkout." >&2
exit 1
}
# A directory of this job's own (mode 0700, a name that nothing else
# uses, so a host runner that keeps its temporary directory between
# jobs does not share it). On any way out of this step but the last
# line, the step removes it itself; the directory is left only for the
# fetch step, which removes it in turn. Its name goes to the later
# steps first, so that the cleanup step finds it even if this step is
# killed.
key_dir="$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/voelin-protocol-key.XXXXXX")"
installed=
trap '[[ -n "$installed" ]] || rm -rf "$key_dir"' EXIT
echo "VOELIN_PROTOCOL_KEY_DIR=$key_dir" >> "$GITHUB_ENV"
key_file="$key_dir/id"
# Whatever the secret store did to the line ends and the final newline,
# OpenSSH needs LF lines, the BEGIN line first and a newline at the end.
printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' > "$key_file"
unset PROTOCOL_DEPLOY_KEY
chmod 600 "$key_file"
if ! public=$(ssh-keygen -y -f "$key_file" < /dev/null); then
echo "::error::VOELIN_PROTOCOL_DEPLOY_KEY is not an unencrypted OpenSSH or PEM private key." >&2
exit 1
fi
# The fingerprint of the public half, to compare with the deploy key in
# the VoelinProtocol settings.
printf 'Deploy key installed: %s\n' "$(ssh-keygen -lf - <<< "$public")"
echo "VOELIN_PROTOCOL_KEY=installed" >> "$GITHUB_ENV"
installed=1
# The only step that uses the key, and the only place that sets
# GIT_SSH_COMMAND: not in GITHUB_ENV, so no later step has it.
- name: Fetch the dependencies with the deploy key
run: |
set -euo pipefail
if [[ "${VOELIN_PROTOCOL_KEY:-}" != installed || -z "${VOELIN_PROTOCOL_KEY_DIR:-}" ]]; then
echo "::error::The deploy key was not installed by the step before (the check at the start of the job or the key step did not pass its flag on)." >&2
exit 1
fi
key_dir="$VOELIN_PROTOCOL_KEY_DIR"
key_file="$key_dir/id"
# On every way out of this step, a failed fetch included.
trap 'rm -rf "$key_dir"' EXIT
[[ -f "$key_file" ]] || { echo "::error::The deploy key file is missing." >&2; exit 1; }
# The system git runs this ssh command, so the key and the host key are
# named outright and nothing in ~/.ssh or /etc/ssh is read: -F /dev/null
# leaves out every ssh config file, -i with IdentitiesOnly and no agent
# offers this one key, and the only host key accepted is the reviewed
# line in .gitea/known_hosts, never one fetched now (a changed or unknown
# host key fails rather than asks). The paths are absolute: Cargo runs
# git in its own directory under CARGO_HOME, not in the checkout.
export GIT_TERMINAL_PROMPT=0
export GIT_SSH_COMMAND="ssh -F /dev/null -i '$key_file' -o IdentitiesOnly=yes -o IdentityAgent=none -o UserKnownHostsFile='$GITHUB_WORKSPACE/.gitea/known_hosts' -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=yes -o BatchMode=yes -o ConnectTimeout=30"
# The first thing that touches the server with the key, so that a wrong
# key or a changed host key fails here with a clear message and not
# minutes later inside Cargo.
if ! timeout 120 git ls-remote --exit-code \
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git HEAD > /dev/null; then
echo "::error::git cannot read Voelin/VoelinProtocol over SSH with the deploy key. 'Permission denied (publickey)' above: the key is not registered on that repository (or is not the one in VOELIN_PROTOCOL_DEPLOY_KEY). 'Host key verification failed': .gitea/known_hosts no longer matches the server (docs/ci.md, VoelinProtocol access)." >&2
exit 1
fi
echo "Voelin/VoelinProtocol is readable with the deploy key."
# Cargo reads the manifests and Cargo.lock and downloads every package
# of the lock file (all targets: cargo deny and cargo about, later, read
# the whole graph). It runs no build script, procedural macro or test
# of the repository. Nothing else in the job needs the key: every later
# cargo command is --offline.
cargo fetch --locked
unset GIT_SSH_COMMAND
rm -rf "$key_dir"
[[ ! -e "$key_dir" ]] || { echo "::error::The deploy key could not be removed from the job." >&2; exit 1; }
echo "The deploy key is removed from the job."
# Whatever happened to the two steps above (a failed fetch, a key that was
# installed and never fetched with, a cancelled job), the key is gone before
# the checks start. Idempotent: the fetch step has already removed it.
- name: Delete the deploy key
if: always()
run: |
set -euo pipefail
key_dir="${VOELIN_PROTOCOL_KEY_DIR:-}"
if [[ -n "$key_dir" && -e "$key_dir" ]]; then
rm -rf "$key_dir"
[[ ! -e "$key_dir" ]] || { echo "::error::The deploy key could not be removed from the job." >&2; exit 1; }
echo "The deploy key is removed from the job."
else
echo "No deploy key is left in the job."
fi
{
echo "VOELIN_PROTOCOL_KEY_DIR="
echo "VOELIN_PROTOCOL_KEY="
} >> "$GITHUB_ENV"
# Formatting, Clippy, build, tests, dependency policy, notices: all
# offline, in a job that holds no key (docs/ci.md, "VoelinProtocol access").
- uses: ./.gitea/actions/checks
with:
# A repository secret is not visible inside the composite action, so
# it is passed in. Pull requests from forks get no secrets: the
# action then fails at once with a message that says so.
protocol-deploy-key: ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }}