Skip to content

test(ci): implement yaml checking tests for changed Docker image #9

test(ci): implement yaml checking tests for changed Docker image

test(ci): implement yaml checking tests for changed Docker image #9

name: "Build and push YAML linter Docker image"
on:
push:
branches:
- "main"
paths:
- ".dockerignore"
- ".yamllint"
- "Dockerfile"
permissions:
contents: "read"
packages: "write"
id-token: "write"
env:
REGISTRY: "ghcr.io"
IMAGE_NAME: "articola-tools/yaml-linter"
jobs:
build-and-push:
runs-on: "ubuntu-latest"
# NOTE: building and pushing Docker image of YAML linter take around 1 minute.
# If this job takes more than 5 minutes, it means that something is wrong.
timeout-minutes: 5
steps:
- name: "Checkout ${{ github.event.repository.name }}"
uses: "actions/checkout@v4"
- name: "Add short hash of current commit to environment variables"
run: "echo \"CURRENT_COMMIT_SHORT_HASH=$(git rev-parse --short \"$GITHUB_SHA\")\" >> \"$GITHUB_ENV\""
- name: "Set up Docker Buildx"
uses: "docker/setup-buildx-action@v3"
- name: "Login to Docker registry"
uses: "docker/login-action@v3"
with:
registry: "${{ env.REGISTRY }}"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: "Build and push YAML linter Docker image"
uses: "docker/build-push-action@v6"
id: "build-and-push"
with:
# NOTE: setup of `context` is needed to force builder to use the `.dockerignore` file.
context: "."
push: true
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.CURRENT_COMMIT_SHORT_HASH }}"