Skip to content

Add languages by filename (#55) #23

Add languages by filename (#55)

Add languages by filename (#55) #23

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.
name: Create and publish a Docker image
on:
workflow_dispatch:
push:
branches:
- main
paths:
- '**.html'
- '**.css'
- '**.js'
- '**.py'
- '**.toml'
- '**.svg'
concurrency:
cancel-in-progress: true
group: ci-${{ github.ref }}
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
env:
GIT_SHA: ${GITHUB_SHA::7}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Generate lowername image
id: image-name
run: |
echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> "${GITHUB_OUTPUT}"
env:
IMAGE_NAME: '${{ env.IMAGE_NAME }}'
- name: Get short SHA
id: slug
run: echo "GIT_SHORT_SHA7=$(echo ${GITHUB_SHA} | cut -c1-7)" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ steps.meta.outputs.tags }}
ghcr.io/${{ steps.image-name.outputs.IMAGE_NAME_LC }}:${{ steps.slug.outputs.GIT_SHORT_SHA7 }}
ghcr.io/${{ steps.image-name.outputs.IMAGE_NAME_LC }}:latest
labels: ${{ steps.meta.outputs.labels }}