fix subtitle parsing #72
This file contains 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: Build and Push Docker Images | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
attestations: write | |
actions: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.DOCKER_GITHUB_TOKEN }} | |
- name: Determine modified folders | |
id: changes | |
run: | | |
if git rev-parse HEAD^ >/dev/null 2>&1; then | |
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD | grep -o '^[^/]*' | sort -u) | |
else | |
CHANGED_FILES=$(git diff --name-only HEAD | grep -o '^[^/]*' | sort -u) | |
fi | |
FOLDERS_WITH_DOCKERFILE="" | |
for folder in $CHANGED_FILES; do | |
if [[ -f "$folder/Dockerfile" ]]; then | |
FOLDERS_WITH_DOCKERFILE="$FOLDERS_WITH_DOCKERFILE $folder" | |
fi | |
done | |
FOLDERS_WITH_DOCKERFILE=$(echo "$FOLDERS_WITH_DOCKERFILE" | xargs) | |
if [ -n "$FOLDERS_WITH_DOCKERFILE" ]; then | |
echo "CHANGED_FOLDERS=$FOLDERS_WITH_DOCKERFILE" >> $GITHUB_ENV | |
else | |
echo "CHANGED_FOLDERS=" >> $GITHUB_ENV | |
fi | |
- name: Build and push Docker images | |
if: env.CHANGED_FOLDERS != '' | |
id: build_push | |
run: | | |
# Build all images first | |
for folder in $CHANGED_FOLDERS; do | |
if [ -f "$folder/Dockerfile" ]; then | |
IMAGE_NAME="ghcr.io/${{ github.actor }}/$folder" | |
BUILD_OUTPUT=$(docker buildx build \ | |
--label "org.opencontainers.image.source=https://github.com/${{ github.repository }}" \ | |
--label "org.opencontainers.image.description=Public container image for $folder" \ | |
--label "org.opencontainers.image.licenses=AGPL-3.0" \ | |
--push \ | |
--platform linux/amd64 \ | |
-t $IMAGE_NAME \ | |
--provenance=false \ | |
--output type=image,push=true \ | |
$folder 2>&1) | |
DIGEST=$(echo "$BUILD_OUTPUT" | grep "pushing manifest.*@sha256:" | head -n1 | sed 's/.*@\(sha256:[a-f0-9]*\).*/\1/' | tr -d '\n\r') | |
# Generate attestation for each image individually | |
echo "image_names=$IMAGE_NAME" >> $GITHUB_OUTPUT | |
echo "image_digests=$DIGEST" >> $GITHUB_OUTPUT | |
echo "Generating attestation for $IMAGE_NAME" | |
gh workflow run generate_attestation.yml \ | |
-f image_name=$IMAGE_NAME \ | |
-f image_digest=$DIGEST \ | |
-R ${{ github.repository }} | |
fi | |
done | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |