Skip to content
Draft
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Keep third-party GitHub Actions on reviewed, immutable updates.
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
43 changes: 26 additions & 17 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ on:
jobs:
build-amd64:
name: Build container (amd64)
if: github.event_name == 'push'
runs-on: ${{ inputs.runs-on-amd64 }}
permissions:
contents: read
packages: write
outputs:
tag: ${{ steps.prepare.outputs.tag }}
repo: ${{ steps.prepare.outputs.repo }}
digest: ${{ steps.build.outputs.digest }}
steps:
- name: Checkout code
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
ref: ${{ github.event.pull_request.head.sha }}
allow-unsafe-pr-checkout: true
ref: ${{ github.sha }}
persist-credentials: false

- name: Prepare variables
Expand All @@ -53,18 +56,18 @@ jobs:
echo "repo=${REPO_NAME}" >> "$GITHUB_OUTPUT"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0

- name: Login to GitHub Container Registry
uses: docker/login-action@v4
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
id: build
uses: docker/build-push-action@v7
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: ${{ inputs.context }}
file: ${{ inputs.file }}
Expand All @@ -79,15 +82,18 @@ jobs:

build-arm64:
name: Build container (arm64)
if: github.event_name == 'push'
runs-on: ${{ inputs.runs-on-arm64 }}
permissions:
contents: read
packages: write
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- name: Checkout code
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
ref: ${{ github.event.pull_request.head.sha }}
allow-unsafe-pr-checkout: true
ref: ${{ github.sha }}
persist-credentials: false

- name: Prepare variables
Expand All @@ -99,18 +105,18 @@ jobs:
echo "repo=${REPO_NAME}" >> "$GITHUB_OUTPUT"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0

- name: Login to GitHub Container Registry
uses: docker/login-action@v4
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
id: build
uses: docker/build-push-action@v7
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: ${{ inputs.context }}
file: ${{ inputs.file }}
Expand All @@ -125,21 +131,24 @@ jobs:

create-manifest:
name: Create multi-arch manifest
if: github.event_name == 'push'
runs-on: ${{ inputs.runs-on-arm64 }}
permissions:
contents: read
packages: write
needs: [build-amd64, build-arm64]
steps:
- name: Checkout code
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
ref: ${{ github.event.pull_request.head.sha }}
allow-unsafe-pr-checkout: true
ref: ${{ github.sha }}
persist-credentials: false

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0

- name: Login to GitHub Container Registry
uses: docker/login-action@v4
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand Down
58 changes: 39 additions & 19 deletions .github/workflows/build-depends.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
check-cache:
name: Check cache
runs-on: ${{ inputs.runs-on }}
permissions:
actions: read
contents: read
outputs:
cache-hit: ${{ steps.cache-check.outputs.cache-hit }}
cache-key: ${{ steps.setup.outputs.cache-key }}
Expand All @@ -49,11 +52,11 @@ jobs:
sdk-artifact: ${{ steps.prepare-sdks.outputs.artifact }}
steps:
- name: Checkout code
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
ref: ${{ github.event.pull_request.head.sha }}
allow-unsafe-pr-checkout: true
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
allow-unsafe-pr-checkout: ${{ github.event_name == 'pull_request_target' }}
sparse-checkout: |
ci/dash
ci/test
Expand All @@ -66,17 +69,20 @@ jobs:

- name: Compute cache key
id: setup
env:
BUILD_TARGET: ${{ inputs.build-target }}
BASE_IMAGE_DIGEST: ${{ inputs.base-image-digest }}
run: |
BUILD_TARGET="${{ inputs.build-target }}"
source ./ci/dash/matrix.sh
echo "DEP_OPTS=${DEP_OPTS}" >> "${GITHUB_OUTPUT}"
echo "HOST=${HOST}" >> "${GITHUB_OUTPUT}"
echo "RUNNER_ARCH=$(uname -m)" >> "${GITHUB_OUTPUT}"
RUNNER_ARCH="$(uname -m)"
echo "RUNNER_ARCH=${RUNNER_ARCH}" >> "${GITHUB_OUTPUT}"
DEP_HASH="$(echo -n "${BUILD_TARGET}" "${DEP_OPTS}" "${HOST}" | sha256sum | head -c 64)"
echo "DEP_HASH=${DEP_HASH}" >> "${GITHUB_OUTPUT}"
DOCKERFILE_HASH="${{ hashFiles('contrib/containers/ci/ci.Dockerfile', 'contrib/containers/ci/ci-slim.Dockerfile') }}"
PACKAGES_HASH="${{ hashFiles('depends/packages/*', 'depends/Makefile') }}"
CACHE_KEY_PREFIX="depends-${DOCKERFILE_HASH}-${{ inputs.base-image-digest }}-${{ inputs.runs-on }}-${{ inputs.build-target }}"
CACHE_KEY_PREFIX="depends-${DOCKERFILE_HASH}-${BASE_IMAGE_DIGEST}-${RUNNER_ARCH}-${BUILD_TARGET}"
CACHE_KEY="${CACHE_KEY_PREFIX}-${DEP_HASH}-${PACKAGES_HASH}"
echo "cache-key-prefix=${CACHE_KEY_PREFIX}" >> "${GITHUB_OUTPUT}"
echo "cache-key=${CACHE_KEY}" >> "${GITHUB_OUTPUT}"
Expand All @@ -85,15 +91,15 @@ jobs:

- name: Check for cached depends
id: cache-check
uses: actions/cache@v5
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: depends/built/${{ steps.setup.outputs.HOST }}
key: ${{ steps.setup.outputs.cache-key }}
lookup-only: true

- name: Cache SDKs
id: cache-sdk-check
uses: actions/cache@v5
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
if: inputs.build-target == 'mac'
with:
path: depends/SDKs
Expand All @@ -109,11 +115,18 @@ jobs:
./contrib/containers/guix/scripts/setup-sdk
echo "artifact=depends-sdks-${BUILD_TARGET}" >> "${GITHUB_OUTPUT}"

- name: Save SDKs cache
if: github.event_name == 'push' && steps.prepare-sdks.outputs.artifact != ''
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: depends/SDKs
key: depends-sdks-${{ hashFiles('depends/hosts/darwin.mk') }}

- name: Upload prepared SDKs
# This originates in check-cache so both Build depends (when needed)
# and Build source can use it even when a PR cannot save the cache.
if: steps.prepare-sdks.outputs.artifact != ''
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: ${{ steps.prepare-sdks.outputs.artifact }}
path: depends/SDKs
Expand All @@ -126,29 +139,36 @@ jobs:
needs: [check-cache]
if: needs.check-cache.outputs.cache-hit != 'true'
runs-on: ${{ inputs.runs-on }}
permissions:
actions: read
contents: read
packages: read
outputs:
built-artifact: depends-built-${{ inputs.build-target }}
container:
image: ${{ inputs.container-path }}
credentials:
username: ${{ github.actor }}
password: ${{ github.token }}
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
ref: ${{ github.event.pull_request.head.sha }}
allow-unsafe-pr-checkout: true
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
allow-unsafe-pr-checkout: ${{ github.event_name == 'pull_request_target' }}

- name: Restore depends sources
uses: actions/cache/restore@v5
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: depends/sources
key: depends-sources-${{ hashFiles('depends/packages/*') }}
restore-keys: depends-sources-

- name: Restore SDKs cache
id: sdk-cache
uses: actions/cache/restore@v5
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
if: inputs.build-target == 'mac'
with:
path: depends/SDKs
Expand All @@ -157,7 +177,7 @@ jobs:

- name: Download prepared SDKs
if: inputs.build-target == 'mac' && steps.sdk-cache.outputs.cache-hit != 'true' && needs.check-cache.outputs.sdk-artifact != ''
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.check-cache.outputs.sdk-artifact }}
path: depends/SDKs
Expand All @@ -170,7 +190,7 @@ jobs:
shell: bash

- name: Restore cached depends
uses: actions/cache/restore@v5
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: depends/built/${{ needs.check-cache.outputs.host }}
key: ${{ needs.check-cache.outputs.cache-key }}
Expand All @@ -186,8 +206,8 @@ jobs:
# Cache tokens on untrusted triggers are read-only (GitHub change,
# June 2026), so only trusted events can save the persistent cache
# for later read-only restores.
if: github.event_name != 'pull_request_target'
uses: actions/cache/save@v5
if: github.event_name == 'push'
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: depends/built/${{ needs.check-cache.outputs.host }}
key: ${{ needs.check-cache.outputs.cache-key }}
Expand All @@ -196,7 +216,7 @@ jobs:
# Same-run handoff to build-src.yml for runs that cannot save the
# cache. Uploaded on every fresh build (cache/save only warns when
# the write is denied), so src jobs never depend on a save landing.
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: depends-built-${{ inputs.build-target }}
path: depends/built/${{ needs.check-cache.outputs.host }}
Expand Down
Loading
Loading