Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
150 changes: 150 additions & 0 deletions .github/workflows/maint-sync-action-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Maint Sync Action Versions

# Sync GitHub Action versions from .github/workflows to templates
# after Dependabot merges action version updates.
#
# This ensures templates stay in sync with the latest action versions
# that Dependabot updates in the main workflows.

on:
push:
branches: [main]
paths:
- '.github/workflows/*.yml'
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
sync-versions:
name: Sync action versions to templates
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Extract action versions from workflows
id: extract
run: |
set -euo pipefail

# Extract unique action versions from .github/workflows/
declare -A versions

for file in .github/workflows/*.yml; do
while IFS= read -r line; do
# Match 'uses: owner/action@version'
if [[ "$line" =~ uses:[[:space:]]*([^[:space:]]+)@(v[0-9]+) ]]; then
action="${BASH_REMATCH[1]}"
version="${BASH_REMATCH[2]}"
# Store highest version for each action
if [[ -z "${versions[$action]:-}" ]] || [[ "$version" > "${versions[$action]}" ]]; then
versions["$action"]="$version"
Comment thread
stranske marked this conversation as resolved.
Outdated
fi
fi
done < "$file"
done

# Output versions for key actions
echo "checkout=${versions[actions/checkout]:-v4}" >> "$GITHUB_OUTPUT"
echo "github_script=${versions[actions/github-script]:-v7}" >> "$GITHUB_OUTPUT"
echo "upload_artifact=${versions[actions/upload-artifact]:-v4}" >> "$GITHUB_OUTPUT"
echo "download_artifact=${versions[actions/download-artifact]:-v4}" >> "$GITHUB_OUTPUT"
echo "cache=${versions[actions/cache]:-v4}" >> "$GITHUB_OUTPUT"

echo "Detected versions:"
for action in "${!versions[@]}"; do
echo " $action: ${versions[$action]}"
done

- name: Update templates with synced versions
id: update
run: |
set -euo pipefail

checkout="${{ steps.extract.outputs.checkout }}"
github_script="${{ steps.extract.outputs.github_script }}"
upload_artifact="${{ steps.extract.outputs.upload_artifact }}"
download_artifact="${{ steps.extract.outputs.download_artifact }}"
cache="${{ steps.extract.outputs.cache }}"

changed=0

# Update all YAML files in templates/
find templates/ -name "*.yml" -type f | while read -r file; do
orig_hash=$(md5sum "$file" | cut -d' ' -f1)

sed -i \
-e "s|actions/checkout@v[0-9]\+|actions/checkout@${checkout}|g" \
-e "s|actions/github-script@v[0-9]\+|actions/github-script@${github_script}|g" \
-e "s|actions/upload-artifact@v[0-9]\+|actions/upload-artifact@${upload_artifact}|g" \
-e "s|actions/download-artifact@v[0-9]\+|actions/download-artifact@${download_artifact}|g" \
-e "s|actions/cache@v[0-9]\+|actions/cache@${cache}|g" \
"$file"

new_hash=$(md5sum "$file" | cut -d' ' -f1)
if [[ "$orig_hash" != "$new_hash" ]]; then
echo "Updated: $file"
changed=1
fi
done

echo "changed=$changed" >> "$GITHUB_OUTPUT"
Comment thread
stranske marked this conversation as resolved.
Outdated

- name: Check for changes
id: check
run: |
if git diff --quiet templates/; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
echo "No changes to templates"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
echo "Changes detected:"
git diff --stat templates/
fi

- name: Create PR if changes exist
if: steps.check.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail

branch="auto/sync-action-versions-$(date +%Y%m%d%H%M%S)"

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git checkout -b "$branch"
git add templates/
git commit -m "ci(deps): sync action versions to templates

Automated sync from .github/workflows/ to templates/

Updated versions:
- actions/checkout: ${{ steps.extract.outputs.checkout }}
- actions/github-script: ${{ steps.extract.outputs.github_script }}
- actions/upload-artifact: ${{ steps.extract.outputs.upload_artifact }}
- actions/download-artifact: ${{ steps.extract.outputs.download_artifact }}
- actions/cache: ${{ steps.extract.outputs.cache }}"

git push origin "$branch"

gh pr create \
--title "ci(deps): sync action versions to templates" \
--body "Automated PR to sync GitHub Action versions from \`.github/workflows/\` to \`templates/\`.

This ensures templates stay in sync with Dependabot updates.

**Updated versions:**
- actions/checkout: \`${{ steps.extract.outputs.checkout }}\`
- actions/github-script: \`${{ steps.extract.outputs.github_script }}\`
- actions/upload-artifact: \`${{ steps.extract.outputs.upload_artifact }}\`
- actions/download-artifact: \`${{ steps.extract.outputs.download_artifact }}\`
- actions/cache: \`${{ steps.extract.outputs.cache }}\`" \
--label "dependencies" \
--label "github-actions"
60 changes: 60 additions & 0 deletions scripts/sync_action_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# Sync GitHub Action versions from .github/workflows/ to templates/
# Run this after Dependabot updates are merged to keep templates in sync.
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(dirname "$SCRIPT_DIR")"

cd "$REPO_ROOT"

# Extract versions from .github/workflows/
declare -A versions

echo "Extracting versions from .github/workflows/..."
for file in .github/workflows/*.yml; do
while IFS= read -r line; do
if [[ "$line" =~ uses:[[:space:]]*([^[:space:]]+)@(v[0-9]+) ]]; then
action="${BASH_REMATCH[1]}"
version="${BASH_REMATCH[2]}"
if [[ -z "${versions[$action]:-}" ]] || [[ "$version" > "${versions[$action]}" ]]; then
versions["$action"]="$version"
Comment thread
stranske marked this conversation as resolved.
Outdated
fi
fi
done < "$file"
done

echo ""
echo "Detected versions:"
for action in "${!versions[@]}"; do
echo " $action: ${versions[$action]}"
done

checkout="${versions[actions/checkout]:-v4}"
github_script="${versions[actions/github-script]:-v7}"
upload_artifact="${versions[actions/upload-artifact]:-v4}"
download_artifact="${versions[actions/download-artifact]:-v4}"
cache="${versions[actions/cache]:-v4}"

echo ""
echo "Updating templates/..."

# Update templates
find templates/ -name "*.yml" -type f | while read -r file; do
orig=$(cat "$file")

sed -i \
-e "s|actions/checkout@v[0-9]\+|actions/checkout@${checkout}|g" \
-e "s|actions/github-script@v[0-9]\+|actions/github-script@${github_script}|g" \
-e "s|actions/upload-artifact@v[0-9]\+|actions/upload-artifact@${upload_artifact}|g" \
-e "s|actions/download-artifact@v[0-9]\+|actions/download-artifact@${download_artifact}|g" \
-e "s|actions/cache@v[0-9]\+|actions/cache@${cache}|g" \
"$file"

if [[ "$(cat "$file")" != "$orig" ]]; then
echo " Updated: $file"
fi
done

echo ""
echo "Done. Run 'git diff templates/' to see changes."
6 changes: 3 additions & 3 deletions templates/ci-basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -42,7 +42,7 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
Expand Down
8 changes: 4 additions & 4 deletions templates/ci-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
name: Smoke Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -55,7 +55,7 @@ jobs:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -78,7 +78,7 @@ jobs:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -103,7 +103,7 @@ jobs:
# CUSTOMIZE: Python versions to test
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
security_reason: ${{ steps.security_gate.outputs.reason }}
steps:
- name: Checkout (for security gate)
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
sparse-checkout: |
.github/scripts/prompt_injection_guard.js
Expand Down Expand Up @@ -492,7 +492,7 @@ jobs:
PY

- name: Upload metrics artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: agents-autofix-metrics
path: autofix-metrics.ndjson
Expand Down
4 changes: 2 additions & 2 deletions templates/consumer-repo/.github/workflows/agents-guard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
steps:
- name: Checkout base ref for safety validation
if: github.event_name == 'pull_request_target'
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.base.sha }}
sparse-checkout: |
Expand All @@ -58,7 +58,7 @@ jobs:

- name: Checkout PR head for pull_request event
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
sparse-checkout: |
.github/scripts/agents-guard.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ jobs:
steps:
# Dual checkout pattern: consumer repo for context, Workflows repo for scripts
- name: Checkout consumer repository
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
path: consumer

- name: Checkout Workflows scripts
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: stranske/Workflows
ref: main
Expand Down Expand Up @@ -282,7 +282,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Workflows scripts
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: stranske/Workflows
ref: main
Expand Down Expand Up @@ -342,7 +342,7 @@ jobs:
environment: agent-standard
steps:
- name: Checkout Workflows scripts
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: stranske/Workflows
ref: main
Expand Down Expand Up @@ -419,7 +419,7 @@ jobs:
echo "$metrics_json" >> keepalive-metrics.ndjson

- name: Upload keepalive metrics artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: keepalive-metrics
path: keepalive-metrics.ndjson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
steps:
- name: Resolve PR context
id: resolve
uses: actions/github-script@v8
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.issue;
Expand Down
2 changes: 1 addition & 1 deletion templates/consumer-repo/.github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
steps:
- name: Resolve PR context
id: context
uses: actions/github-script@v8
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Locate latest Gate workflow run
id: discover
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:

- name: Download coverage trend artifact
if: ${{ steps.discover.outputs.run_id }}
uses: actions/download-artifact@v4
uses: actions/download-artifact@v7
continue-on-error: true
with:
name: gate-coverage-trend
Expand All @@ -89,7 +89,7 @@ jobs:

- name: Download coverage artifact
if: ${{ steps.discover.outputs.run_id }}
uses: actions/download-artifact@v4
uses: actions/download-artifact@v7
continue-on-error: true
with:
pattern: gate-coverage-*
Expand Down
Loading
Loading