mirror of
https://github.com/ivuorinen/actions.git
synced 2026-01-26 11:34:00 +00:00
111 lines
3.9 KiB
YAML
111 lines
3.9 KiB
YAML
---
|
|
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
|
|
name: Build Testing Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- '_tools/docker-testing-tools/**'
|
|
- '.github/workflows/build-testing-image.yml'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- '_tools/docker-testing-tools/**'
|
|
- '.github/workflows/build-testing-image.yml'
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Docker image tag'
|
|
required: false
|
|
default: 'latest'
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
build-and-push:
|
|
name: Build and Push Testing Image
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@71cf2267d89c5cb81562390fa70a37fa40b1305e # v6-beta
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0
|
|
with:
|
|
images: ghcr.io/${{ github.repository_owner }}/actions
|
|
tags: |
|
|
type=ref,event=branch,suffix=-testing-tools
|
|
type=ref,event=pr,suffix=-testing-tools
|
|
type=raw,value=testing-tools,enable={{is_default_branch}}
|
|
type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event.inputs.tag != '' }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
|
with:
|
|
context: _tools/docker-testing-tools
|
|
file: _tools/docker-testing-tools/Dockerfile
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
- name: Test image
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
# Test the built image works correctly
|
|
docker run --rm ghcr.io/${{ github.repository_owner }}/actions:testing-tools shellspec --version
|
|
docker run --rm ghcr.io/${{ github.repository_owner }}/actions:testing-tools act --version
|
|
docker run --rm ghcr.io/${{ github.repository_owner }}/actions:testing-tools trivy --version
|
|
|
|
- name: Generate image summary
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
{
|
|
echo "## 🐋 Docker Image Built Successfully"
|
|
echo ""
|
|
echo "**Image**: \`ghcr.io/${{ github.repository_owner }}/actions:testing-tools\`"
|
|
echo "**Tags**: ${{ steps.meta.outputs.tags }}"
|
|
echo ""
|
|
echo "### Usage in GitHub Actions"
|
|
echo ""
|
|
echo "\`\`\`yaml"
|
|
echo "jobs:"
|
|
echo " test:"
|
|
echo " runs-on: ubuntu-latest"
|
|
echo " container: ghcr.io/${{ github.repository_owner }}/actions:testing-tools"
|
|
echo " steps:"
|
|
echo " - uses: actions/checkout@v5"
|
|
echo " - run: shellspec _tests/unit/your-action/"
|
|
echo "\`\`\`"
|
|
echo ""
|
|
echo "### Pre-installed Tools"
|
|
echo "- ShellSpec"
|
|
echo "- nektos/act (latest)"
|
|
echo "- Trivy security scanner (latest)"
|
|
echo "- TruffleHog secrets scanner (latest)"
|
|
echo "- actionlint (latest)"
|
|
echo "- shellcheck, jq, kcov, GitHub CLI"
|
|
echo "- Node.js LTS, Python 3, build tools"
|
|
} >> "$GITHUB_STEP_SUMMARY"
|