Update README #856
This file contains hidden or 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: Update README | |
| 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 URL and Tag Version | |
| run: | | |
| JSON_RESPONSE=$(curl -s https://api.github.com/repos/Sparticuz/chromium/releases/latest) | |
| TAG_VERSION=$(echo $JSON_RESPONSE | grep -Po '"tag_name": "\K[^"]+') | |
| echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV | |
| - name: Update README | |
| run: | | |
| TAG_VERSION=${{ env.TAG_VERSION }} | |
| ARN_BASE="arn:aws:lambda:" | |
| ACCOUNT_ID="764866452798" | |
| 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 |