Skip to content

Update README

Update README #857

name: Update README
# This workflow runs AFTER "Deploy Layers" completes successfully.
# No version checking is needed here because:
# 1. Deploy Layers already checks for new versions and skips if none exist
# 2. Deploy Layers updates .tag_version before this workflow runs
# 3. If this workflow is triggered, README should always be updated
on:
# push:
# branches:
# - master
workflow_run:
workflows: ["Deploy Layers"]
types:
- completed
jobs:
update_readme:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
AWS_REGIONS: "us-east-1 us-east-2 us-west-1 us-west-2 ca-central-1 eu-central-1 eu-west-1 eu-west-2 eu-west-3 eu-north-1 ap-northeast-1 ap-northeast-2 ap-southeast-1 ap-southeast-2 ap-south-1 sa-east-1"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup AWS CLI
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Get Latest Release Info
run: |
JSON_RESPONSE=$(curl -s https://api.github.com/repos/Sparticuz/chromium/releases/latest)
TAG_VERSION=$(echo $JSON_RESPONSE | grep -Po '"tag_name": "\K[^"]+')
# Get layer file sizes for both architectures and convert to MB
X64_SIZE_BYTES=$(echo $JSON_RESPONSE | grep -Po '"name": "chromium-[^"]+-layer\.x64\.zip"[^}]*"size": \K[0-9]+' | head -1)
ARM64_SIZE_BYTES=$(echo $JSON_RESPONSE | grep -Po '"name": "chromium-[^"]+-layer\.arm64\.zip"[^}]*"size": \K[0-9]+' | head -1)
if [[ -n "$X64_SIZE_BYTES" ]]; then
X64_SIZE_MB=$((X64_SIZE_BYTES / 1024 / 1024))
echo "X64_SIZE_MB=$X64_SIZE_MB" >> $GITHUB_ENV
fi
if [[ -n "$ARM64_SIZE_BYTES" ]]; then
ARM64_SIZE_MB=$((ARM64_SIZE_BYTES / 1024 / 1024))
echo "ARM64_SIZE_MB=$ARM64_SIZE_MB" >> $GITHUB_ENV
fi
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
- name: Update README
run: |
TAG_VERSION=${{ env.TAG_VERSION }}
X64_SIZE_MB=${{ env.X64_SIZE_MB }}
ARM64_SIZE_MB=${{ env.ARM64_SIZE_MB }}
ARN_BASE="arn:aws:lambda:"
ACCOUNT_ID="764866452798"
sed -i -e "s|> .*compressed with Brotli|> ${X64_SIZE_MB} MB (x64) / ${ARM64_SIZE_MB} MB (arm64) Chromium layer for AWS Lambda compressed with Brotli|g" readme.md
sed -i -e "s|Has Chromium v[0-9\.]*|Has Chromium $TAG_VERSION|g" readme.md
for REGION in ${{ env.AWS_REGIONS }}; do
X64_VERSION=$(aws lambda list-layer-versions --layer-name chrome-aws-lambda-x64 --region $REGION --query 'LayerVersions[0].Version' --output text 2>/dev/null || echo "1")
ARM64_VERSION=$(aws lambda list-layer-versions --layer-name chrome-aws-lambda-arm64 --region $REGION --query 'LayerVersions[0].Version' --output text 2>/dev/null || echo "1")
X64_ARN="$ARN_BASE$REGION:$ACCOUNT_ID:layer:chrome-aws-lambda-x64:$X64_VERSION"
ARM64_ARN="$ARN_BASE$REGION:$ACCOUNT_ID:layer:chrome-aws-lambda-arm64:$ARM64_VERSION"
sed -i -e "s|arn:aws:lambda:$REGION:[0-9]*:layer:chrome-aws-lambda-x64:[0-9]*|$X64_ARN|g" readme.md
sed -i -e "s|arn:aws:lambda:$REGION:[0-9]*:layer:chrome-aws-lambda-arm64:[0-9]*|$ARM64_ARN|g" readme.md
done
- name: Commit and Push
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
if ! git diff --quiet readme.md; then
git add readme.md
git commit -m "Update README with new version details [ci skip]"
git push
echo "README updated and pushed"
else
echo "No changes to README, skipping commit"
fi