Repository navigation
Compare Templates against Images #247
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Compare Templates against Images" | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: '0 2 * * 1-5' | |
| workflow_dispatch: | |
| inputs: | |
| assignee: | |
| description: "GitHub username to assign the drift tracking issue to. Leave empty to assign to the Copilot coding agent (default)." | |
| required: false | |
| type: string | |
| default: '' | |
| permissions: | |
| contents: read | |
| jobs: | |
| check-image-tags: | |
| name: Check Image Tags (Last Release) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: List template images | |
| run: npx tsx build/list-template-images.ts | |
| - uses: actions/checkout@v5 | |
| with: | |
| repository: devcontainers/images | |
| fetch-depth: 0 | |
| path: images | |
| - name: Check out last release tag | |
| run: | | |
| cd images | |
| tag=$(git describe --tags --abbrev=0) | |
| echo "Checking out tag: $tag" | |
| git checkout "$tag" | |
| - name: Check image tags (last release) | |
| run: npx tsx build/check-image-tags.ts images | |
| check-image-tags-latest: | |
| name: Check Image Tags (Latest) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/checkout@v5 | |
| with: | |
| repository: devcontainers/images | |
| path: images | |
| - name: Check image tags (latest) | |
| run: | | |
| if ! npx tsx build/check-image-tags.ts images; then | |
| echo "::warning::Image tag check against latest images failed - upcoming release may break templates" | |
| fi | |
| report-drift-issue: | |
| name: Report Drift and Assign to Copilot | |
| # Only run on manual dispatch - never on schedule/PRs/pushes, so we don't open | |
| # issues automatically. Scheduled runs skip this job. | |
| if: github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Generate a token | |
| id: app-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ vars.DEVCONTAINERS_REPO_AUTOMATION_ID }} | |
| private-key: ${{ secrets.DEVCONTAINERS_REPO_AUTOMATION_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| repositories: | | |
| templates | |
| images | |
| - uses: actions/checkout@v5 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| - uses: actions/checkout@v5 | |
| with: | |
| repository: devcontainers/images | |
| token: ${{ steps.app-token.outputs.token }} | |
| fetch-depth: 0 | |
| path: images | |
| - name: Check out last release tag | |
| run: | | |
| cd images | |
| tag=$(git describe --tags --abbrev=0) | |
| echo "Checking out tag: $tag" | |
| git checkout "$tag" | |
| - name: Run comparison and capture report | |
| id: compare | |
| run: | | |
| set +e | |
| npx tsx build/check-image-tags.ts images > report.txt 2>&1 | |
| status=$? | |
| # Strip ANSI colour codes so the report is readable inside an issue. | |
| sed -i -E 's/\x1B\[[0-9;]*m//g' report.txt | |
| cat report.txt | |
| if grep -qE '^[[:space:]]*(MISSING|UNUSED)' report.txt; then | |
| echo "has_drift=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_drift=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create or refresh tracking issue and assign | |
| if: steps.compare.outputs.has_drift == 'true' | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| ASSIGNEE_LOGIN: ${{ github.event.inputs.assignee }} | |
| run: bash build/report-drift-issue.sh report.txt |