name: Gitea release key # Early warning for the signature check of the gitea role: roles/gitea/tasks/download.yml # accepts a release only when it carries a valid signature by gitea_gpg_key_id (or a subkey), # so an expired, revoked or replaced Gitea release key makes every install and update fail # closed. scripts/check_gitea_release_key.py reads the pins from roles/gitea/defaults/main.yml, # fetches the key and the pinned release's .asc (never the binary) and fails when a key expires # within 60 days, is revoked or expired, or did not sign the release. It checks the issuers and # the key, not the signature itself (no binary), so a corrupt .asc still fails only in the role. # What to do on a failure is in the script's docstring. # # Weekly, by hand, and on pull requests that change the pins (a Renovate bump of gitea_version # is checked against the new release's signature) or the check itself. Runs only on the # Collection's own runner. Read-only; no org secret, the only credential is the job token # (secrets.GITHUB_TOKEN), which is read-only for a fork pull request. No pull_request_target. # Not a required check: it depends on the key source and dl.gitea.com being reachable. on: # yamllint disable-line rule:truthy schedule: # Every Monday at 06:00 UTC - cron: "0 6 * * 1" workflow_dispatch: {} pull_request: branches: - main paths: - roles/gitea/defaults/main.yml - scripts/check_gitea_release_key.py - tests/scripts/test_check_gitea_release_key.py - .gitea/workflows/gitea-release-key.yml permissions: contents: read # A newer push to the same pull request makes the running run obsolete; a scheduled or # manual run on main keeps its own result. concurrency: group: gitea-release-key-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: check: runs-on: kamino-docker timeout-minutes: 10 # The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the # release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here. container: image: git.rkdr.net/mortis/ci:0.2.44@sha256:ba153980c5824b81c62eb3cfc871694d126bc6c4c21814813a0fde87873494f6 steps: # The container has no Node, so JavaScript actions such as actions/checkout # cannot run; clone with git and the job token. - name: Checkout the commit under test env: GIT_CONFIG_COUNT: "1" GIT_CONFIG_KEY_0: http.extraheader GIT_CONFIG_VALUE_0: "AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}" SHA: ${{ github.event.pull_request.head.sha || github.sha }} REF: ${{ github.ref }} REPO_URL: ${{ github.server_url }}/${{ github.repository }} run: | git clone "$REPO_URL" . # A clone has no refs/pull/*: fetch the run's ref when the sha is not on a branch. git checkout "$SHA" || { git fetch origin "$REF" && git checkout "$SHA"; } echo "Checked out $(git rev-parse HEAD)" # The ci image has gpgv (apt's verifier) but not gpg: the check needs gpg to read the key # and the signature packets, and the tests need gpg-agent to make throwaway keys. Installed # per run from the image's own Ubuntu archive (apt verifies it) rather than baked in, so # this check is not an input of the ci image. The tests skip their key cases without gpg, # gpg-agent or gpgconf, so this step fails when any of the three is missing. - name: Install gpg run: | apt-get update -qq apt-get install -y -qq --no-install-recommends gpg gpg-agent for c in gpg gpg-agent gpgconf; do command -v "$c" > /dev/null || { echo "::error::$c is missing"; exit 1; }; done gpg --version | head -n1 # Offline, with throwaway keys: the check itself works before it judges the real key. - name: Test the check run: /opt/venv/bin/python3 -I tests/scripts/test_check_gitea_release_key.py - name: Check the Gitea release key and the pinned release's signature run: /opt/venv/bin/python3 -I scripts/check_gitea_release_key.py --window-days 60