mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
d97953f101
* ci: Reduce chance of installing corrupt packages See: https://dev.to/hsbt/should-rubygemsbundler-have-a-cooldown-feature-40cp Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: prevent credential leakage from checkout steps Add `persist-credentials: false` to all `actions/checkout` calls across 22 workflow files. Without this, the GitHub token used for checkout is written into `.git/config` and remains accessible to all subsequent steps and any uploaded artifacts (artipacked finding). Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: prevent template injection from github context in run steps `${{ github.* }}` expressions used directly inside `run:` blocks are expanded before the shell sees them. A crafted value (e.g. a tag name containing shell metacharacters) would execute arbitrary code. Move the values into `env:` variables (e.g. GITHUB_EVENT_RELEASE_TAG_NAME, GITHUB_ACTOR) and reference them as `${VAR}` in the shell, so the runtime never interprets them as code (template-injection finding). Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: prevent injection in yq commands via release tag name `${{ github.event.release.tag_name }}` was interpolated directly into yq `cmd:` inputs. A crafted tag name could inject shell commands since the expression is expanded before the action runs. Use yq's `strenv()` with an `env:` variable instead so the value is always treated as data. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: pin all GitHub Actions to full commit SHAs Actions pinned to mutable tags (e.g. @v6, @main) can change under us if the upstream repo is compromised or tags are moved, enabling supply-chain attacks. Pinning to the full 40-char commit SHA locks the exact code that runs. Version tags are preserved as inline comments (e.g. # v6.0.2) for readability and Dependabot compatibility. Used `pinact` for standard tagged versions; remaining branch-based references (mikefarah/yq, jlumbroso/free-disk-space, project-stacker/stacker-build-push-action, aquasecurity/trivy-action) resolved manually via the GitHub API. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: slow down GitHub Actions dependency updates to biweekly Dependabot has no native biweekly interval. Combining weekly checks with a 14-day cooldown achieves the same effect: Dependabot scans every Monday but won't open a PR for a new action version until 14 days after release, giving the ecosystem time to stabilize before we adopt it. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: group all Dependabot updates into single PRs per ecosystem Without groups, Dependabot opens one PR per dependency. With `patterns: "*"`, all Go module bumps land in one PR and all GitHub Actions pin updates in another, reducing review noise. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: restore credential persistence for helm-charts push `persist-credentials: false` was too broad — the helm-charts checkout uses HELM_PUSH_TOKEN specifically so the subsequent `git push` can authenticate. Only the main repo checkout should have credentials disabled. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: use --password-stdin for oras login Passing the token via `-p` exposes it in process listings and debug logs. Piping via stdin is the standard secure pattern for CLI auth. Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> * ci: pin actions to versioned release SHAs jmgilman/actions-generate-checksum: v1 branch HEAD -> v1.0.1 release mikefarah/yq: arbitrary master HEAD -> v4.52.5 release Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr> --------- Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
139 lines
5.1 KiB
YAML
139 lines
5.1 KiB
YAML
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
release:
|
|
types:
|
|
- published
|
|
name: build
|
|
|
|
permissions: read-all
|
|
|
|
jobs:
|
|
build-arch:
|
|
name: Build ZOT multiarch
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
os: [linux, darwin, freebsd, windows]
|
|
arch: [amd64, arm64]
|
|
steps:
|
|
- name: Check out source code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
- name: Install go
|
|
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
|
|
with:
|
|
cache: false
|
|
check-latest: true
|
|
go-version: 1.25.x
|
|
- name: Cache go dependencies
|
|
id: cache-go-dependencies
|
|
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
|
|
with:
|
|
path: |
|
|
~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-mod-
|
|
- name: Cache go build output
|
|
id: cache-go-build
|
|
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
|
|
with:
|
|
path: |
|
|
~/.cache/go-build
|
|
key: ${{ matrix.os }}-${{ matrix.arch }}-go-build-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ matrix.os }}-${{ matrix.arch }}-go-build-
|
|
- name: Install go dependencies
|
|
if: steps.cache-go-dependencies.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd $GITHUB_WORKSPACE
|
|
go mod download
|
|
- name: Install other dependencies
|
|
run: |
|
|
cd $GITHUB_WORKSPACE
|
|
go install github.com/swaggo/swag/cmd/swag@v1.16.2
|
|
sudo apt-get update
|
|
sudo apt-get install rpm
|
|
sudo apt-get install snapd
|
|
sudo apt-get install libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config python3-jsonschema
|
|
git clone https://github.com/containers/skopeo -b v1.12.0 $GITHUB_WORKSPACE/src/github.com/containers/skopeo
|
|
cd $GITHUB_WORKSPACE/src/github.com/containers/skopeo && \
|
|
make bin/skopeo && \
|
|
sudo cp bin/skopeo /usr/bin && \
|
|
rm -rf $GITHUB_WORKSPACE/src/github.com/containers/skopeo
|
|
cd $GITHUB_WORKSPACE
|
|
curl -Lo notation.tar.gz https://github.com/notaryproject/notation/releases/download/v1.0.0-rc.4/notation_1.0.0-rc.4_linux_amd64.tar.gz
|
|
sudo tar xvzf notation.tar.gz -C /usr/bin notation
|
|
rm -f notation.tar.gz
|
|
- name: Run build
|
|
timeout-minutes: 10
|
|
run: |
|
|
echo "Building for $OS:$ARCH"
|
|
cd $GITHUB_WORKSPACE
|
|
make binary binary-minimal binary-debug cli bench exporter-minimal
|
|
env:
|
|
OS: ${{ matrix.os }}
|
|
ARCH: ${{ matrix.arch }}
|
|
|
|
- name: Generate GraphQL Introspection JSON on Release
|
|
if: github.event_name == 'release' && github.event.action == 'published' && matrix.os == 'linux' && matrix.arch == 'amd64'
|
|
run: |
|
|
bin/zot-linux-amd64 serve examples/config-search.json &
|
|
sleep 10
|
|
curl -X POST -H "Content-Type: application/json" -d @.pkg/debug/githubWorkflows/introspection-query.json http://localhost:5000/v2/_zot/ext/search | jq > bin/zot-gql-introspection-result.json
|
|
pkill zot
|
|
|
|
- name: Generate zot config schema on Release
|
|
if: github.event_name == 'release' && github.event.action == 'published' && matrix.os == 'linux' && matrix.arch == 'amd64'
|
|
run: |
|
|
make verify-config-schema
|
|
|
|
- if: github.event_name == 'release' && github.event.action == 'published'
|
|
name: Publish artifacts on releases
|
|
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # latest
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
file: bin/z*
|
|
tag: ${{ github.ref }}
|
|
overwrite: true
|
|
file_glob: true
|
|
|
|
release-checksums:
|
|
name: Release Artifact Checksums
|
|
needs: build-arch
|
|
if: github.event_name == 'release' && github.event.action == 'published'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
steps:
|
|
- name: Download Release Artifacts
|
|
uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1
|
|
with:
|
|
tag: ${{ github.ref_name }}
|
|
fileName: "z*"
|
|
- name: Generate checksum
|
|
uses: jmgilman/actions-generate-checksum@3ea6dc9bf8eecf28e2ecc982fab683484a1a8561 # v1.0.1
|
|
with:
|
|
patterns: z*
|
|
method: sha256
|
|
output: checksums.sha256.txt
|
|
- name: Add wildcard character prefix to filenames in checksum file
|
|
run: sed -i 's! ! \*!g' checksums.sha256.txt
|
|
- name: Publish checksums on releases
|
|
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # latest
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
file: checksums.sha256.txt
|
|
tag: ${{ github.ref }}
|
|
overwrite: true
|